I want to know that users submit their data for the last 2 days I have 2 fields in my table: USERID and DATE_SUBMITTED I have data in my table for the past 2 days but my query is not returning to any data. I am doing the wrong here:
choose different [UserID], DT_ myTable has been submitted where [UserID] = 'Joe' and 'D' submitted = (Choose CAST (FOREST (CAST (GETDATE) - 1) AS FLOAT ()) and DT_ submitted = (select Cast (Floor (CAST (GETDATE) - 2S Float) AS DATETIME))
Thank you
SELECT UserID, DT_ myTable submitted in FROM (- Select both days 'User', 'DATEADD' (DAY, -1, GETDATE ()) DT_ submit Selected Union All 'UserID', DATEADD (DAY, -2, GETDATE ()) DT_ submitted union all - Select a day 'Bob', DATEAD (DAY, -1, GETDATE ()) DT_ Submitted union all - Submit 5 days ago SELECT 'Helen', DATEADD (DAY, -5, GETDATE ()) submitted DT_) SELECT * FROM (SELE CT user ID, - all calculations of submissions in the last two days And then they send them to SM (in case when CAST (DT_ submitted date) = DATEADD (DAY, -1, CAST (GETDATE (up to DATE)) 1 WHEN CAST (submitted as DT_ date) = DATEADD (DA Y-2, CAST (as GETDATE (DATE)) then 1 ELSE 0 END) as submission by UserID from MyTable GROUP where the submission = 2
Results:
UserID submissions ------ ----------- which is 2
No comments:
Post a Comment