我有下表:年
data
----
2005-07-12-09.21.54.000000
2005-07-12-13.58.58.000000
2005-10-17-22.36.32.000000
2005-09-17-16.34.38.000000
2005-10-29-13.31.26.000000
2002-07-16-15.23.13.000000
我想用year函数截断它,然后计算年份。所以基本上是这样的:
year count
------ -------
2005 5
2002 1
我尝试过不同的东西,但我仍然无法计算它应该是什么样子。
select year(date) as year,
count(date) as count
from years
group by date;
这给了我以下输出:
YEAR COUNT
-------- ----------
2000 1
2005 1
2005 1
2005 1
2005 1
2005 1
有人能帮我吗?谢谢
按year(date)
:分组
select year(date) as year,
count(date) as count
from years
group by year(date);