View Single Post
  #2 (permalink)  
Old March 25th, 2008, 02:29 PM
dparsons dparsons is offline
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I just ran this query against one of my tables, it should work for you:

SELECT top 10 id, url, DatePart(month, Last_Updated) from menus order by DatePart(month, Last_Updated) desc, id asc


This gave me results like this:

ID URL MONTH
7 foo 3
8 foo 3
9 foo 3
1 foo 2
2 foo 2
etc...

Does this work for you?

[edit]
Actually you will probably want a query similar to this instead:

SELECT top 10 id, url, datepart(month, Last_Updated) from menus order by DatePart(month, Last_Updated)desc, id desc

Which gives results like this:
ID URL MONTH
9 foo 3
8 foo 3
7 foo 3
2 foo 2
1 foo 2
etc...

So if the ID column where the amount column it is always going highest to lowest based on descending month.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote