Hi, I am trying to get my query show five highest numbers of accidents,e.g.
postcode AccidentCount
NG7 12
NG8 10
SW12 5
so far i've got this:
SELECT Job.Postcode,
COUNT ([Job].[JobType]) AS AccidentCount
FROM Job
WHERE JobType='Accident'
GROUP BY Postcode;
and it gives me a nice list of postcodes and the corresponding counts of accidents. i was thinking of adding a subquery
(SELECT JobType AS AccidentCount
FROM Job
WHERE JobType='Accident'
ORDER BY AccidentCount DESC LIMIT 0,5)
so my final query is:
Code:
SELECT Job.Postcode,
COUNT ([Job].[JobType]) AS AccidentCount
(SELECT JobType AS AccidentCount
FROM Job
WHERE JobType='Accident'
ORDER BY AccidentCount DESC LIMIT 0,5)
FROM Job
WHERE JobType='Accident'
GROUP BY Postcode;
but it doesn't work. could anyone please help me to get it right? Thanks