SELECT DQ,
max(case TYPE when '汽车' then count else 0 end) 汽车,
max(case TYPE when '货车' then count else 0 end) 货车
from
(
select DQ,
'汽车' as type,
count(DQ) as count
from TABLE_NAME
where DELETE_FLAG = '00'
and TIME > to_date('2021-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
group by DQ
union ALL
select DQ,
'货车' as type,
count(DQ) as count
from TABLE_NAME
where DELETE_FLAG = '00'
and TIME > to_date('2021-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
group by DQ
)
group by DQ
order by instr('合肥市,芜湖市,蚌埠市,淮南市,马鞍山市,淮北市,铜陵市,安庆市,宿松县,
黄山市,滁州市,阜阳市,宿州市,六安市,亳州市,池州市,宣城市,广德县', DQ)
某一列查询结果,作为结果集的查询列
于 2022-02-09 10:45:12 首次发布