May 2, 2008 at 7:47 am
There's another way of doing this:
SELECT dbJobSkillGrp,
SUM(CASE WHEN dbJobCreateDate BETWEEN @StartDate AND @EndDate THEN 1 ELSE 0 END) AS 'JobsCreated',
SUM(CASE WHEN dbJobFillDate BETWEEN @StartDate AND @EndDate THEN 1 ELSE 0 END) AS 'JobsFilled',
SUM(CASE WHEN dbJobCreateDate BETWEEN @StartDate AND @EndDate AND dbJobStatus = 'Vacant' THEN 1 ELSE 0 END) AS 'JobsVacant'
FROM ftjoborder
GROUP BY dbJobSkillGrp
ORDER BY dbJobSkillGrp
Not better, just different.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing post 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply