TA的每日心情 | 衰 2017-3-15 09:05 |
---|
签到天数: 152 天 连续签到: 2 天 [LV.7]测试师长
|
select count(*) from sys_base sb where sysbase_tag = 'AQ'
and sb.sysbase_id in (
select y.syscorp_district from
(
select x.*
from (select to1.*,
ROW_NUMBER() OVER(PARTITION BY to1.t_user_id, to1.t_disaster_id ORDER BY back_time desc) as myrowid,
td1.tname,
tu.syscorp_id ,
sc.syscorp_district
from t_order to1
left join t_disaster td1 on td1.t_disaster_id =
to1.t_disaster_id
left join t_user tu on tu.t_user_id = to1.t_user_id
left join sys_corp sc on sc.syscorp_id = tu.syscorp_id
where 1 = 1
and back_time is not null
and (to1.t_task_id = 2 or to1.t_task_id = 0)) x
where x.myrowid = 1 -- and back_disaster_id = 104
) y
)
order by to_number(regexp_substr(sysbase_id,'[0-9]*[0-9]',1)) |
|