0
我在做日期轉換時並不那麼強大。我確信我因時間戳而丟失記錄。我需要在此查詢中轉換我的日期,以便我可以獲得滾動的季度日期總和。任何幫助將非常感謝和提前感謝。做日期轉換
SELECT
a.UserID_Caller ,a.csCallType,timewait,a.convotime,datename(quarter,timewait)as qrt,datename(year,timewait)as yr,datename(month,timewait)as mnth,datename(day,timewait)as dy
--sum(case when datename(year,timewait) = (datename(year,getdate()-1)) AND (datename(Quarter,timewait))=(datename(Quarter,getdate()-1)) and (datename(day,timewait))<>(datename(day,getdate()))then (a.convotime)/60 else 0 end) as [MTD]
FROM satVRS.dbo.rptNECACallHistory as a
WHERE
a.IsReport = 1
-AND (datename(year,timewait))=(datename(year,getdate()-1)) AND (datename(quarter,timewait))=(datename(quarter,getdate()-1)) and (datename(day,timewait))<>(datename(day,getdate()))
and month(timewait)
AND a.convotime > 0
AND a.NECA_isReport = 1
AND a.Video in ('SV')
GROUP BY a.UserID_Caller ,a.csCallType,timewait,a.convotime
order by timewait,a.UserID_Caller
您能否提供一些示例數據來說明您的季度到目前爲止的含義? –
以下是一些示例數據,我將會以convotime的方式獲取每日總數,MTD,QTD和YTD – user3027644