a为主表
b为流程表
把主表和流程表的最后一条操作记录选出来
我现在这么些的,貌似不大好。
select * from a,
(select max(flow_id),list_id from b group by list_id) b
where a.list_id=b.list_id
我还想把b表中其他信息取出来,请问怎么写?每个字段上都加个函数?select * from a,
(select max(flow_id),max(...),max(...) list_id from b group by list_id) b
where a.list_id=b.list_id
b为流程表
把主表和流程表的最后一条操作记录选出来
我现在这么些的,貌似不大好。
select * from a,
(select max(flow_id),list_id from b group by list_id) b
where a.list_id=b.list_id
我还想把b表中其他信息取出来,请问怎么写?每个字段上都加个函数?select * from a,
(select max(flow_id),max(...),max(...) list_id from b group by list_id) b
where a.list_id=b.list_id
select b.*,row_number() over(partition by list_id order by flow_id desc) rn
from b如果取最大的一条
select * from (
select b.*,row_number() over(partition by list_id order by flow_id desc) rn
from b) where rn=1