SQL Server Note

パート単位でグループ化

SELECT BUYDATE FROM PC
BUYDATE
1900-01-01 00:00:00.000
NULL
2000-03-15 14:10:05.000
1995-06-13 00:00:00.000
2001-01-11 18:20:15.000
2000-03-12 00:00:00.000
2000-08-01 00:00:00.000
1999-12-16 13:50:52.000
2001-01-11 01:03:18.000
SELECT
YEAR(BUYDATE) AS [YEAR],
COUNT(*) AS [CNT]
FROM PC
GROUP BY YEAR(BUYDATE)
YEARCNT
NULL1
19001
19951
19991
20003
20012
Copyright © 2006 Hikijishi All Rights Reserved.
[] [sql][0.00100207328796387]