SELECT import_custom,MONTH(import_custom),SUM(import_number) FROM 表a GROUP BY import_custom,MONTH(import_custom) ORDER BY import_custom,MONTH(import_custom)
SELECT a.import_custom,MONTH(a.import_custom),SUM(isnull(a.import_number,0)) FROM 表a right join (select 1 as m union all select 2 as m union all .. select 12 as m ) b on MONTH(a.import_custom)=b.m GROUP BY a.import_custom,MONTH(a.import_custom) ORDER BY a.import_custom,MONTH(a.import_custom)
SELECT a.import_custom,isnull(MONTH(a.import_custom),b.m),SUM(isnull(a.import_number,0)) FROM 表a right join ( select 1 as m union all select 2 as m union all .. select 12 as m ) b on MONTH(a.import_custom)=b.m GROUP BY a.import_custom,isnull(MONTH(a.import_custom),b.m) ORDER BY a.import_custom,isnull(MONTH(a.import_custom),b.m)
select a.import_custom, b.mon,(select sum(import_number) from 表 where import_custom = a.import_custom and month(import_date) =b.mon ) from 表 a, (select 1 as mon union all select 1 as mon union all .... select 12 as mon ) b group by a.import_custom,b.mon
FROM 表a
GROUP BY import_custom,MONTH(import_custom)
ORDER BY import_custom,MONTH(import_custom)
FROM 表a right join
(select 1 as m union all
select 2 as m union all
..
select 12 as m ) b on MONTH(a.import_custom)=b.m
GROUP BY a.import_custom,MONTH(a.import_custom)
ORDER BY a.import_custom,MONTH(a.import_custom)
FROM 表a right join
( select 1 as m union all
select 2 as m union all
..
select 12 as m ) b on MONTH(a.import_custom)=b.m
GROUP BY a.import_custom,isnull(MONTH(a.import_custom),b.m)
ORDER BY a.import_custom,isnull(MONTH(a.import_custom),b.m)
select a.import_custom, b.mon,(select sum(import_number) from 表
where import_custom = a.import_custom and month(import_date) =b.mon )
from 表 a,
(select 1 as mon union all
select 1 as mon union all
....
select 12 as mon
) b
group by a.import_custom,b.mon