may be my question is too confusing,
but actually this means can't solve my problems.
i have a table,
item quantity
P001 2
P023 4
P001 5....
ps. the item is not the key, it can't code can appear many times in this
column.
i want to group the item frist, then use sum() to find out the total quanity
of each item. and limit to the first three rows..
i have tried this:
select item, "sum(quantity" from
( select item, sum(quantity)
from tbl_name
group by item order by sum(quantity)
) where rownum <= 3;
how ever, i 've tried different silimar methods,
it seems that, the subquery cannot include a order clause.
how can i solve it.
can , am i cross post,
cos i dun know what should i post, i choose this newsgroup, because i am
using orcale...
Ivan Bajon <iba_at_no_spam_at_post1.tele.dk> wrote in message
news:832u1l$3g0$1_at_news.inet.tele.dk...
> select a, b, c from your_table
> where rownum < 4
> order by b;
>
> hth,
> Ivan Bajon, ocp
>
>
>
> Zenith <jackyleo_at_attmysite.com> wrote in message
> news:830rsb$jae$1_at_m5.att.net.hk...
> > I have learning sqlplus currently in a Oracle 7, sqlplus.
> > how can I list out the records in ascending order of one field?
> > if it can be done,
> > and how can i just selected the first three rows? with the use of a
> > function?
> > or i can only do this by a very long sql statment?
> >
> >
>
>
Received on Mon Dec 13 1999 - 14:41:12 CST