Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Urgent : Help needed in writing a SQL query

 
Raj Sikka
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have a table TEMP which has three columns say COL1,COL2,COL3
The data in that table is like :
COL1 COL2 COL3
--------------------------
1 65536 1
1 65536 2
1 65537 1
1 65537 1
1 65538 2
I need to write a query which displays results;
65536 1
65537 1
65538 2
i,e, For each distinct COL2 get the minimum of COL3.
Please help.
Thanks in advance,
Sree
 
SJ Adnams
Ranch Hand
Posts: 925
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
select col2, min(col3) from temp group by col2;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic