April 4, 2013 at 7:59 am
hey guys
need some help with a query!!!
basically i have a table that has a list of learner with a number of aims. i want to do a query that will tell me how many learners there are under 1 aim 2 aims 3 aims etc
this is what ive tried already for 1 aim but how would i doit for 2 3 4 aims and so on.
SELECT COUNT (A.N#OfAims) AS N#OfLearners
FROM
(
SELECT L01, L03, COUNT (DISTINCT A09) AS N#OfAims
FROM [LSC_MI_db_pub].[dbo].[_AIMS_SN14]
GROUP BY L01, L03
)AS A
WHERE A.N#OfAims = 1
April 4, 2013 at 8:26 am
mamzy.rahman (4/4/2013)
hey guysneed some help with a query!!!
basically i have a table that has a list of learner with a number of aims. i want to do a query that will tell me how many learners there are under 1 aim 2 aims 3 aims etc
this is what ive tried already for 1 aim but how would i doit for 2 3 4 aims and so on.
SELECT COUNT (A.N#OfAims) AS N#OfLearners
FROM
(
SELECT L01, L03, COUNT (DISTINCT A09) AS N#OfAims
FROM [LSC_MI_db_pub].[dbo].[_AIMS_SN14]
GROUP BY L01, L03
)AS A
WHERE A.N#OfAims = 1
can you please post the DDL?
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
April 5, 2013 at 10:44 am
I may be completely misunderstanding, but surely if you miss out the WHERE clause (and maybe replace it with "ORDER BY COUNT (A.N#OfAims)"), then this will give you all the aim counts.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply