Connecting Tech Pros Worldwide Help | Site Map

asp order by two clauses.

Familiar Sight
 
Join Date: Jul 2006
Posts: 181
#1: Aug 27 '09
Hi, I wonder if anyone knows how I would order the following.

I have two categories, 1 and 2

I want to order the results on the page according to the last update so I have
order by lastupdate desc

But I want to give priority to category 1, so in effect all category 1s are at the top followed by category 2 but all sorted by the lastupdate desc.

If anyone has any ideas thats great
Thanks
Richard
GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 143
#2: Aug 28 '09

re: asp order by two clauses.


Would

Expand|Select|Wrap|Line Numbers
  1. ORDER BY Category_1, Category_2 DESC
  2.  
do the trick?

So for example Category_1 column would be listed 1 through 10 and any numbers in those categories would have Category_2 listed 10 through 1:

1 1
2 1
3 3
3 2
3 1
4 1
5 1

Is that what you mean?

Gaz.
Familiar Sight
 
Join Date: Jul 2006
Posts: 181
#3: Aug 28 '09

re: asp order by two clauses.


Thanks Gaz, Yes that did the trick perfectly.
Thanks a lot
Richard
Reply


Similar ASP / Active Server Pages bytes