想选出每条hphm的相关信息,要求hphm不能相同,下面的语句并不能实现,因为每个clbh的值都不相同,所以会出现相同的hphm
select distinct(hphm),clbh from xxfl where jllx='0' and scbj=0 and (jgsj between to_date( '2008-08-30 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2008-08-30 15:00:00','yyyy-mm-dd hh24:mi:ss'));
请教各位不吝赐教
select distinct(hphm),clbh from xxfl where jllx='0' and scbj=0 and (jgsj between to_date( '2008-08-30 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2008-08-30 15:00:00','yyyy-mm-dd hh24:mi:ss'));
请教各位不吝赐教
select hphm,max(clbh) from xxfl
where jllx='0' and scbj=0
and (jgsj between to_date( '2008-08-30 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2008-08-30 15:00:00','yyyy-mm-dd hh24:mi:ss'))
group by hphm;
SELECT HPHM,MAX(CLBH) FROM ... GROUP BY HPHM;SELECT HPHM,CLBH FROM (..., ROW_NUMBER() OVER(PARTITION BY HPHM ORDER BY HPHM) "RN" ...) ... RN = 1;
SELECT HPHM,CLBH FROM (..., RANK() OVER(PARTITION BY HPHM ORDER BY HPHM) "RO" ...) ... RO = 1;
SELECT HPHM,CLBH FROM (..., DENSE_RANK() OVER(PARTITION BY HPHM ORDER BY HPHM) "DR" ...) ... DR = 1;