drop table tab_break_point;
create table TAB_BREAK_POINT
(
tab_namevarchar2(20),
BILLING_LINE_ID NUMBER(9),
POINT_VALUE NUMBER(15),
CREATE_DATE DATE
);
insert into tab_break_point values ('TEST1',1000123,0,sysdate);
insert into tab_break_point values ('TEST1',1000123,30,sysdate+1/20);
insert into tab_break_point values ('TEST1',1000123,90,sysdate+1/10);
我想取出tab_name和billing_line_id作为一个分组,我每次取出日期最新的记录的create_value值,该如何取
我写了这个,感觉太土了,有简洁一些的吗,谢谢!
比如当前我就是取90的值
selectpoint_value
from tab_break_point
where tab_name = 'TEST1'
and billing_line_id = '1000123'
and create_date in
(select create_date
from (select tab_name,
billing_line_id,
max(create_date) create_date
from tab_break_point wheretab_name = 'TEST1'
and billing_line_id = '1000123'
group by tab_name, billing_line_id));
[ 本帖最后由 wabjtam123 于 2009-9-17 16:10 编辑 ]
|