请问在SQL里怎么计算天数
一张表report里面有StartDate,FinishDate两列,请问怎么计算出天数,再以天数降序排列
SELECT DATEDIFF([Day], StartDate, FinishDate) AS Expr1, *
FROM Table3
ORDER BY DATEDIFF([Day], StartDate, FinishDate) DESC
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[report]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[report]
GO
CREATE TABLE [dbo].[report] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[StartDate] [datetime] NOT NULL ,
[FinishDate] [datetime] NOT NULL
) ON [PRIMARY]
GO