Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting issue 1

Status
Not open for further replies.

Chumley40

Programmer
Jan 24, 2005
71
US
I want to count by groups of 7. so, want the first seven rows in my query to be 1, the next 7 to be two, next seven 3, etc.

Any ideas on how to accomplish this?
 
I don't understand. so the first statement you wrote is basically my code with a rownumber added.

the second one, I don't get? What is row%8?
 
% is the modulus operator in SQL Server.

So,
1/7 = 0
2/7 = 0
3/7 = 0

...
7/7 = 1
8/7 = 1

etc.

so, to organize groups of 7, we want to divide our row by 8 and check for the int.

Also, BTW, we don't need to use %. We can use / as two integers will use integer math division.

PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top