1
我需要獲取今年上個月的記錄,但我也記錄了過去幾年的記錄。請幫我如何獲取今年上個月的記錄,
我有這樣的查詢:
select EmpCode,EventDate1 as EventDate,InTime,
case when OutTime is null then 'N/A' else Outtime end as OutTime from
TMS_HOURCALC WHERE DATEPART(m, EventDate) = DATEPART(m, DATEADD(m, -1, getdate()))
and empcode='13658'
GROUP BY EmpCode, InTime,OutTime, EventDate1,intime1
order by intime1;
我試圖執行,但我只有1條記錄與我上面的查詢沒有年標記我有39個記錄! – Hearty
做剩餘的38條記錄屬於往年? –
39條記錄中,23條屬於2012年,其餘16條屬於今年! – Hearty