CREATE TABLE #AvailableDate (
CustomKey INT IDENTITY (1,1),
SelectedFaceID INT,
FromDate DATETIME,
ToDate DATETIME,
TempDate DATETIME,
Diff INT)
INSERT INTO #AvailableDate(SelectedFaceID, FromDate, ToDate, TempDate, Diff)
SELECT
SelectedFaceID,
FromDate,
ToDate,
(SELECT TOP 1 ToDate FROM #AvailableDate WITH(NOLOCK) ORDER BY #AvailableDate.CustomKey DESC),
(SELECT DATEDIFF(
d,
ToDate,
(SELECT TOP 1 ToDate FROM #AvailableDate ORDER BY CustomKey DESC)
)
)
FROM
SelectedFace WITH(NOLOCK)
在这里,我没有得到SELECT TOP 1 ToDate FROM #AvailableDate WITH(NOLOCK) ORDER BY #AvailableDate.CustomKey DESC
上述查询中的值或任何与#AvailableDate