select
[Date]
,sum(V) as V
,sum(C) as C
,sum(E) as E
,sum(M) as M
,sum(G) as G
from
(
select
dateadd(day,datediff(day,0,createdon),0) as [Date]
,case left(columnname,1) when 'v' then 1 else 0 end as V
,case left(columnname,1) when 'c' then 1 else 0 end as C
,case left(columnname,1) when 'e' then 1 else 0 end as E
,case left(columnname,1) when 'm' then 1 else 0 end as M
,case left(columnname,1) when 'g' then 1 else 0 end as G
from tablename
where createdon>'2009-07-01'
) raw
No comments:
Post a Comment