日期:2014-05-18  浏览次数:20568 次

如何造日期列
SQL code

SELECT Uid, SUM(Money), [如何造] FROM USER GROUP BY Uid
表中没有日期列,但是因为需要我想造个日期列,从2012-1-1开始到今天的日期,当然数量都是一样的,只要有日期列就OK



------解决方案--------------------
SQL code

SELECT CONVERT(VARCHAR(10),DATEADD(DAY,number,'2012-01-01'),23) AS Date
FROM master..spt_values
WHERE type = 'P' AND DATEADD(DAY,number,'2012-01-01') <= GETDATE()