Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Next Min Value

Status
Not open for further replies.

thermidor

Programmer
Nov 28, 2001
123
US
All:

Can someone tell me how to get the next min value in a table? For instance if I have a table:

CREATE TABLE test
("ID" NUMBER,
"QTY" NUMBER)

And the table has the following values:

ID QTY
-- ---
01 5
01 10
01 15
02 20
02 5
03 30
03 100
04 200

How can I best query this to get the sums for IDs 01 and 02?
That is, how do I get the result below?

ID QTY
-- ---
01 30
02 25

TIA,
Sven
 

Try:
Code:
select id, qty
  from (
    select id, sum(qty) qty
      from Test Group by id)
  where rownum <=2;
[3eyes]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top