Share via

Partition Function in Access and SQL

Anonymous
2019-09-18T18:58:36+00:00

I could use Partition Function in Access, but not in SQL. I was trying  to add a Column name as

[NumDaysPassed ] =  Partition([NumDaysPassed],1,1000,10) in SQL server. It worked good in Access but not in SQL. Any help will be appreciated. 

Thanks,

I typed the wrong column, sorry for that. Corrected one is : [NumDaysPassed ] =  Partition([Target Days],1,1000,10) in MS Access . This works fine in Access but not in SQL

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Duane Hookom 26,825 Reputation points Volunteer Moderator
    2019-09-19T14:17:45+00:00

    Since your question is about SQL Server syntax, you would have more success in a SQL Server forum. You may have to coach them on the Access function. The solution may involve use of recursion.

    I typically create a table of ranges with min and max values and a title for a task like this.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2019-09-19T11:47:12+00:00

    Since you are simply splitting into 10s are you ok with something like:

    Convert(int, NumDaysPassed/10) * 10 as RoundedDays

    Good morning Duane, 

    Yes, 10s is okay because my database and dates are not so old, so this should be okay. If needed, I will change the range later. This function in Access works but how do I make it work in SQL Server management studio, is the question. 

    Thank you for your inputs,  Duane!

    Was this answer helpful?

    0 comments No comments
  3. Duane Hookom 26,825 Reputation points Volunteer Moderator
    2019-09-18T21:38:14+00:00

    Since you are simply splitting into 10s are you ok with something like:

    Convert(int, NumDaysPassed/10) * 10 as RoundedDays

    Was this answer helpful?

    0 comments No comments