现在的位置: 首页 > 综合 > 正文

行转为列

2013年03月19日 ⁄ 综合 ⁄ 共 309字 ⁄ 字号 评论关闭

select convert(varchar(13),ad_date),sum(f),sum(g),sum(p) from (
select ad_date,case t6_id when 36880 then ad_data end as f,
case t6_id when 36881 then ad_data end as g,
case t6_id when 36882 then ad_data end as p
from t_amdata where am_id=12 and t6_id in(36880,36881,36882)) as z
group by convert(varchar(13),ad_date)
order by convert(varchar(13),ad_date)

抱歉!评论已关闭.