读书人

sql 行转列运用case when then

发布时间: 2012-07-16 15:45:00 作者: rapoo

sql 行转列,使用case when then

?

行转列,使用case when then

?

selectdate,sum(case c.type when 'try-pay' then c.sum else 0 end ) as 'try-pay',sum(case c.type when 'pay-real' then c.sum else 0 end )as 'pay-real',sum(case c.type when 'pay-success' then c.sum else 0 end )as 'pay-success',sum(case c.type when 'pay-failure' then c.sum else 0 end )as 'pay-failure',sum(case c.type when 'notify-input' then c.sum else 0 end )as 'notify-input',sum(case c.type when 'normal-query' then c.sum else 0 end )as 'normal-query'from(SELECT sum(f_count) as sum ,f_type as type ,f_date as date FROM t_log_analyse group by f_type,f_date order by f_date desc) as cgroup by date

?

?

读书人网 >SQL Server

热点推荐