2
我有一个包含ID字段和3个日期时间字段的表。我需要得到每个日期时间字段monthwise.I的数量正在使用按日期时间字段分组
Select to_char(datatime1,'Mon-yyyy'),count(id) from table
where datetime1 is not null
Select to_char(datatime2,'Mon-yyyy'),count(id) from table
where datetime2 is not null
Select to_char(datatime3,'Mon-yyyy'),count(id) from table
where datetime3 is not null
然后我复制这导致到Excel和下面设置数据:
Month CountID(datetime1) CountID(datetime2) CountID(datetime3)
June-2013 50 20 16
July-2013 24 10 56
我在想,如果有一种方式我可以结合这三个查询,而不是一次写入一次查询?
+1我正在做小提琴的答案,但既然你做了第一个......这是小提琴:http://sqlfiddle.com/#!4/d0e9d/3 –
谢谢!伟大的思想家都认为:D –