我需要在下面的查询中添加什么才能获得此查询后显示的第一行?
查询:
SELECT column1,
column2,
MIN (column3),
MIN (colmun4)
FROM table
WHERE column0 = 'value'
GROUP BY column1, column2
当前结果:
column1 column2 column3 column4
30187 C 201330 1/3/2013 2:49:35 PM //I want this row only
33459 C 201330 1/3/2013 4:32:42 PM
90855 C 201390 3/28/2013 9:20:44 AM
96077 RA 201390 7/1/2013 11:31:46 AM
答案 0 :(得分:1)
select * from (
SELECT column1,
column2,
MIN (column3),
MIN (colmun4)
FROM table
WHERE column0 = 'value'
GROUP BY column1, column2)
where rownum = 1
或者如果你正在使用oracle 12c,你可以使用下面的
SELECT column1,
column2,
MIN (column3),
MIN (colmun4)
FROM table
WHERE column0 = 'value'
GROUP BY column1, column2
OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY;