sql语句
select to_char(t.duty_date, 'YYYY-MM-DD') as duty_date,
'441201008' as ORG_ID,
max(decode(t.site_no, '0144004212001', t.teller_no, null)) as a0144004212001,
max(decode(t.site_no, '0144004212002', t.teller_no, null)) as a0144004212002,
max(decode(t.site_no, '0144004212003', t.teller_no, null)) as a0144004212003,
max(decode(t.site_no, '0144004212004', t.teller_no, null)) as a0144004212004,
max(decode(t.site_no, '0144004212005', t.teller_no, null)) as a0144004212005,
max(decode(t.site_no, '0144004212006', t.teller_no, null)) as a0144004212006
from inspect_duty t
where 1 = 1AND t.duty_date >= sysdate
and t.duty_date <= last_day(sysdate)
AND t.org_id = '441201008'
group by t.duty_date
order by t.duty_date
select to_char(t.duty_date, 'YYYY-MM-DD') as duty_date,
'441201008' as ORG_ID,
max(decode(t.site_no, '0144004212001', t.teller_no, null)) as a0144004212001,
max(decode(t.site_no, '0144004212002', t.teller_no, null)) as a0144004212002,
max(decode(t.site_no, '0144004212003', t.teller_no, null)) as a0144004212003,
max(decode(t.site_no, '0144004212004', t.teller_no, null)) as a0144004212004,
max(decode(t.site_no, '0144004212005', t.teller_no, null)) as a0144004212005,
max(decode(t.site_no, '0144004212006', t.teller_no, null)) as a0144004212006
from inspect_duty t
where 1 = 1AND t.duty_date >= sysdate
and t.duty_date <= last_day(sysdate)
AND t.org_id = '441201008'
group by t.duty_date
order by t.duty_date
本文深入解析了一段SQL语句,该语句使用了复杂的聚合查询技巧,包括TO_CHAR函数、DECODER函数及GROUP BY操作,旨在展示如何在日期筛选条件下,按组织ID分组并聚合特定站点编号的告诉号。通过分析这段SQL,读者可以学习到在处理数据时如何高效地应用SQL函数来实现业务需求。

被折叠的 条评论
为什么被折叠?



