November 23, 2022 at 3:06 pm
SELECT StudentId
FROM @student
GROUP BY StudentId
HAVING COUNT(DISTINCT SubmissionDate) > GREATEST(2, DATEDIFF(DAY, MIN(SubmissionDate), MAX(SubmissionDate)));
N 56°04'39.16"
E 12°55'05.25"
November 23, 2022 at 7:28 pm
SELECT StudentId
FROM @student
GROUP BY StudentId
HAVING COUNT(DISTINCT SubmissionDate) > GREATEST(2, DATEDIFF(DAY, MIN(SubmissionDate), MAX(SubmissionDate)));
Unfortunately, GREATEST isn't available in 2019, which is what this forum is.
That is a pretty cool usage of greatest though.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 23, 2022 at 7:59 pm
You can substitute this simple GREATEST with a CASE WHEN THEN END statement.
N 56°04'39.16"
E 12°55'05.25"
November 25, 2022 at 2:56 am
You can substitute this simple GREATEST with a CASE WHEN THEN END statement.
Since GREATEST isn't available in 2019, you should post that change to the code for the OP. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply