Re: where clause help, please
From: david <davidhooey_at_gmail.com>
Date: Thu, 3 Jan 2008 06:06:49 -0800 (PST)
Message-ID: <3ed1741e-f906-4fec-abab-c3757930e485@n23g2000hsh.googlegroups.com>
Date: Thu, 3 Jan 2008 06:06:49 -0800 (PST)
Message-ID: <3ed1741e-f906-4fec-abab-c3757930e485@n23g2000hsh.googlegroups.com>
On Jan 2, 6:12 pm, Totti <saliba.toufic.geo..._at_gmail.com> wrote:
> hi all,
> i want to get the top 3 product that are the most sold, i want to use
> in the where clause, rowNum <= 3 but i dont know what is the exact
> syntax, my attempt is this:
>
> select Prod_Code , sum(qty) from purch
> group by Prod_Code
> order by sum(qty) desc
>
> and from this i want just the first 3, rowNum will do the thing in
> where but would you please tell me how to imply it properly?
>
> thanks.
You can do something like this...
select *
from
(select Prod_Code , sum(qty) from purch
group by Prod_Code
order by sum(qty) desc)
where rownum <= 3
Received on Thu Jan 03 2008 - 08:06:49 CST