感谢您的回答。实际上,我在 plsql 中发现了一些效果很好的东西:
select clientname,
max(decode(trim(dow),'MONDAY',totalquantity,0)) Mon,
max(decode(trim(dow),'TUESDAY',totalquantity,0)) Tue,
max(decode(trim(dow),'WEDNESDAY',totalquantity,0)) Wed,
max(decode(trim(dow),'THURSDAY',totalquantity,0)) Thu,
max(decode(trim(dow),'FRIDAY',totalquantity,0)) Fri,
(
max(decode(trim(dow),'MONDAY',totalquantity,0)) +
max(decode(trim(dow),'TUESDAY',totalquantity,0)) +
max(decode(trim(dow),'WEDNESDAY',totalquantity,0)) +
max(decode(trim(dow),'THURSDAY',totalquantity,0)) +
max(decode(trim(dow),'FRIDAY',totalquantity,0))
) TOTAL
from
(
select clientname,
to_char(tradedate, 'DAY') as dow,
sum(quantity) as totalquantity
from ClientTrade a
where a.tradedate >= trunc(sysdate-7,'D')
and a.tradedate <= trunc(sysdate-7,'D') + 4
group by c.clientshortname, tradedate
)
group by clientname