I次のクエリがあります。SQL名前の変更ロー結果
SELECT * FROM [dbo].[SellThruDaily852] WHERE RetailerID='AMAZON' --order by StartDate
AND StartDate in (20170731,20170801,20170802,20170803,20170804,20170805,20170806);
WITH AMAZON AS
(
SELECT
MAX(ProcessRunId) ProccessID,
DATEPART(YY,DATEADD(DD,-1,CAST(CreatedDate AS DATE))) VizioYear ,
DATEPART(WK,DATEADD(DD,-1,CAST(CreatedDate AS DATE))) WeekID,
CAST(DATENAME(dw,CAST(CreatedDate AS DATE)) AS VARCHAR) DayName,
FileName,
CAST(CreatedDate AS DATE) CreateDate
--CreatedDate
FROM [dbo].[FileCheckResult]
WHERE
RetailerID='AMAZON'
AND FileCheckType='Received'
AND FileDataType='SellThru'
AND FileName like '852_AMAZON_9%'
GROUP BY FileName,CAST(CreatedDate AS DATE)
)
SELECT
*
FROM AMAZON
WHERE
VizioYear=2017
AND WeekID=31
ORDER BY CreateDate
そして、これが結果です:私がやりたいものを
はにDAYNAMEの最初の2つの行を変更です - 月曜日と火曜日。