**这适用于SQL2010
试图找出有多少学生参加每个PGM(即计划)
需要生成包含5列的报告
结果
PGM /节目COUNT很好。
PGM排名
也是如此但学生的学业和学生排名是1。
他们每个人都是“1”。 :(
我想我需要在SELECT中进行SELECT(或者我不太了解SQL)
SELECT TOP 100
T.PGM AS Program,
COUNT(*) AS ProgramCount,
RANK() OVER (ORDER BY COUNT(*) DESC) as ProgramRanking,
T.SID AS 'StudentID',
COUNT(DISTINCT 'StudentID') AS ProgramCount,
RANK() OVER (ORDER BY COUNT(DISTINCT 'StudentID') DESC) as StudentRanking
FROM StudentPrograms T
WHERE T.PGM <>'unknown' AND
T.CreateDate > '2015-10-01' AND
T.CreateDate < '2015-11-01' -- We do LIKE Halloween :)
GROUP BY T.PGM
ORDER BY COUNT(*) DESC;
再次感谢您
答案 0 :(得分:0)
将您的查询更改为:
viewDidLoad