如果不打印null,如何显示具有某些值的月份名称?

时间:2014-05-20 14:49:23

标签: sql sql-server

我有一个表格日期和价格。下面给出了表格结构

Id |Date       |Price
---------------------------
1  |2012-1-1   |300
1  |2012-2-1   |300
1  |2012-3-1   |300
1  |2012-4-1   |300
1  |2012-5-1   |300
1  |2012-6-1   |300
1  |2013-1-1   |300
1  |2013-2-1   |300
1  |2013-3-1   |300
1  |2013-4-1   |300
1  |2013-5-1   |300
1  |2013-6-1   |300

但我只想要相应的日期月份及其价格。如果表格中没有月份,我想添加月份名称,价格为零

 Month|Price
--------------
January |300
February|300
March   |300
April   |300
May     |300
June    |300
July    |0
August  |0
September|0
October |0
November|0
December|0
January |300
February|300
March   |300
April   |300
May     |300
June    |300
July    |0
August  |0
September|0
October |0
November|0
December|0

有人怎么做?

0 个答案:

没有答案