我需要獲取從sqlserver2008r2記錄,我對獲取記錄本周查詢:如何編寫查詢來獲取最後一週的記錄
select EmpCode,EventDate1 as EventDate,InTime,
case when OutTime is null then 'N/A' else Outtime end as OutTime from
TMS_HOURCALC WHERE intime1
BETWEEN dateadd(dd,(datediff(DD,-53684,getdate())/7)*7,-53684)
AND dateadd(dd,((datediff(dd,-53684,getdate())/7)*7)+7,-53684)
and empcode = @empcode
GROUP BY EmpCode, InTime,OutTime, EventDate1,intime1
order by intime1;
請人幫我只能從最後取了上週的記錄週日到週六。
其實我有一些性能問題!謝謝你的建議 – Hearty