Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Counter column that resets at 8th record

Author  Topic 

bi89405
Starting Member

35 Posts

Posted - 2012-03-09 : 18:08:01
Hello,

I am trying to have an additional column to my query that counts the records and when it reaches the 8th record, it resets back to 1 and starts the counter again until it reaches the next 8th record, and so on...

How can I accomplish this? Your assistance is greatly appreciated.

Thanks!
Zack

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2012-03-09 : 18:23:35
1) Create/induce an IDENTITY column that starts at one
2) Select (identCol - 1) % 8 + 1

=================================================
Men shout to avoid listening to one another. -Miguel de Unamuno
Go to Top of Page
   

- Advertisement -