sql查询多张表时间段取时间最晚的一条
select*from(select*from(selectdistincta.ol_idOL_id,a.ol_nbr购物车ID,mm.receive_date消息落地表...
select *
from (select *
from (select distinct a.ol_id OL_id,
a.ol_nbr 购物车ID,
mm.receive_date 消息落地表时间,
a.so_date 购物车抽取时间,
bb.create_date 产品服务定单创建时间,
aa.create_date 资源变更单创建时间,
oo.create_date 流程启动时间,
k.receive_date 报竣时间,
cc.flow_id
from his_wf_event_od mm
join his_srv_tache_order mf
on mf.flow_id = mm.flow_id
join his_srv_crm_tache_order a
on a.to_id = mf.to_id
join his_SRV_B2O_BUSI_ORDER b
on a.to_id = b.to_id
join his_SRV_B2O_BUSI_ORDER_2_PSO bb
on b.action_id = bb.action_id
join his_srv_pso_2_ro aa
on aa.pso_id = bb.pso_id
join his_srv_res_order c
on c.ro_id = aa.ro_id
join his_srv_ro_flow cc
on cc.ro_id = c.ro_id
join his_wf_event_finish k
on cc.flow_id = k.flow_id
join his_srv_ro_event oo
on oo.ro_id = cc.ro_id
where a.ol_id in (250075955915)))
这个我要取流程启动时间最晚的一条需要怎么改呢 展开
from (select *
from (select distinct a.ol_id OL_id,
a.ol_nbr 购物车ID,
mm.receive_date 消息落地表时间,
a.so_date 购物车抽取时间,
bb.create_date 产品服务定单创建时间,
aa.create_date 资源变更单创建时间,
oo.create_date 流程启动时间,
k.receive_date 报竣时间,
cc.flow_id
from his_wf_event_od mm
join his_srv_tache_order mf
on mf.flow_id = mm.flow_id
join his_srv_crm_tache_order a
on a.to_id = mf.to_id
join his_SRV_B2O_BUSI_ORDER b
on a.to_id = b.to_id
join his_SRV_B2O_BUSI_ORDER_2_PSO bb
on b.action_id = bb.action_id
join his_srv_pso_2_ro aa
on aa.pso_id = bb.pso_id
join his_srv_res_order c
on c.ro_id = aa.ro_id
join his_srv_ro_flow cc
on cc.ro_id = c.ro_id
join his_wf_event_finish k
on cc.flow_id = k.flow_id
join his_srv_ro_event oo
on oo.ro_id = cc.ro_id
where a.ol_id in (250075955915)))
这个我要取流程启动时间最晚的一条需要怎么改呢 展开
1个回答
展开全部
select top 1 *
from (select *
from (select distinct a.ol_id OL_id,
a.ol_nbr 购物车ID,
mm.receive_date 消息落地表时间,
a.so_date 购物车抽取时间,
bb.create_date 产品服务定单创建时间,
aa.create_date 资源变更单创建时间,
oo.create_date 流程启动时间,
k.receive_date 报竣时间,
cc.flow_id
from his_wf_event_od mm
join his_srv_tache_order mf
on mf.flow_id = mm.flow_id
join his_srv_crm_tache_order a
on a.to_id = mf.to_id
join his_SRV_B2O_BUSI_ORDER b
on a.to_id = b.to_id
join his_SRV_B2O_BUSI_ORDER_2_PSO bb
on b.action_id = bb.action_id
join his_srv_pso_2_ro aa
on aa.pso_id = bb.pso_id
join his_srv_res_order c
on c.ro_id = aa.ro_id
join his_srv_ro_flow cc
on cc.ro_id = c.ro_id
join his_wf_event_finish k
on cc.flow_id = k.flow_id
join his_srv_ro_event oo
on oo.ro_id = cc.ro_id
where a.ol_id in (250075955915)))
order by oo.create_date desc
from (select *
from (select distinct a.ol_id OL_id,
a.ol_nbr 购物车ID,
mm.receive_date 消息落地表时间,
a.so_date 购物车抽取时间,
bb.create_date 产品服务定单创建时间,
aa.create_date 资源变更单创建时间,
oo.create_date 流程启动时间,
k.receive_date 报竣时间,
cc.flow_id
from his_wf_event_od mm
join his_srv_tache_order mf
on mf.flow_id = mm.flow_id
join his_srv_crm_tache_order a
on a.to_id = mf.to_id
join his_SRV_B2O_BUSI_ORDER b
on a.to_id = b.to_id
join his_SRV_B2O_BUSI_ORDER_2_PSO bb
on b.action_id = bb.action_id
join his_srv_pso_2_ro aa
on aa.pso_id = bb.pso_id
join his_srv_res_order c
on c.ro_id = aa.ro_id
join his_srv_ro_flow cc
on cc.ro_id = c.ro_id
join his_wf_event_finish k
on cc.flow_id = k.flow_id
join his_srv_ro_event oo
on oo.ro_id = cc.ro_id
where a.ol_id in (250075955915)))
order by oo.create_date desc
更多追问追答
追问
只取一条。你这个是倒序
追答
select top 1 *
上面这个就是只取一条
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询