you could put it into a view and then sort than with a select column_name
from view order by column name....
----- Original Message -----
From: "Jeffry Houser" <[EMAIL PROTECTED]>
To: "SQL" <[EMAIL PROTECTED]>
Sent: Wednesday, November 28, 2001 4:09 AM
Subject: Re: DISTINCT COUNT - SQL Server


>   select top 5 count(ProductID) as topfiveproducts, productID
>   from orders
>   order by topfiveproducts desc   ( <-- I don't remember if you can sort
on
> an alias created from aggregate function )
>
>   I also don't think that you would need a distinct clause.
>
> At 12:02 PM 11/28/2001 +0800, you wrote:
> >Hi all,
> >
> >This is probably really simple, but I just can't seem to get it!
> >
> >To simplify, I have an orders table, with a primary key "OrderID", and a
> >foreign key "ProductID". I want to get the top five most ordered
> >products. I thought maybe using a COUNT with DISTINCT, and restricting
> >the rows returned, but how do I ORDER BY?
> >
> >Any help on how to approach this will be greatly appreciated.
> >
> >Thanks,
> >K.
> >
> >
> >
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to