By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,379 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,379 IT Pros & Developers. It's quick & easy.

Adding an autonumber that resets every month

P: 1
I have a simple SQL server table with 4 fields - id, date, transactions.
I want to create an additional column that gives the ranking of each record within that month based on the number of transactions.
Is there any easy way to do this ?
Apr 3 '08 #1
Share this Question
Share on Google+
2 Replies


debasisdas
Expert 5K+
P: 8,127
If you want only for display purpose no need tro create an addition column.
Apr 4 '08 #2

Brad Orders
P: 21
I would suggest that the approach that you take will depend on what you want to do with the data. If you are wanting to only return one month at a time (for example, the user provides a month and you return all the records for the month), then you could query the table, order by Transactions DESC, and put this into a temporary table that has a auto increment. Then you could SELECT the temp table, and the increment would give you the number you are after.

Hope this helps.
Apr 6 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.