quote: Originally posted by sunitabeck I guess NTILE would be useful if you are the College Board and trying to determine what SAT score would correspond to the 95th percentile. But like you, I have not used it much either.
I would be very interested in seeing how to do this with student scores. This might be a better way for me. I tried using PESO's code using what test data, but I don't see how it should be coded or if it is the way.Here is what I have:CREATE TABLE #Scores ( SID INT NOT NULL, TestID VARCHAR(10) NOT NULL, Score DECIMAL(5,2) NOT NULL, MaxScore DECIMAL(5,2) NOT NULL, BeginScore DECIMAL(5,2) NOT NULL, ProgScore DECIMAL(5,2) NOT NULL, ProfScore DECIMAL(5,2) NOT NULL, AdvScore DECIMAL(5,2) NOT NULL)INSERT INTO #ScoresSELECT 12222, 'LA09.01.01', 2.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 13333, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 14444, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 15555, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 16666, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 17777, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 18888, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 19999, 'LA09.01.01', 1.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 21111, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 22222, 'LA09.01.01', 2.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 23333, 'LA09.01.01', 2.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 24444, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 25555, 'LA09.01.01', 1.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 26666, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 27777, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 28888, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 29999, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 31111, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 32222, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 33333, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 34444, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 44221, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 55345, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 66345, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 77345, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 88345, 'LA09.01.01', 4.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 92345, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 93345, 'LA09.01.01', 3.00, 4.00, 1.00, 2.00, 3.00, 4.00UNION SELECT 94445, 'LA09.01.01', 2.00, 4.00, 1.00, 2.00, 3.00, 4.00;WITH cteSource(SID, TestID, Score)AS ( SELECT SID, TestID, NTILE(4) OVER (ORDER BY SID) AS Score FROM #Scores), ctePresentation(TestID, Score, RowNumber)AS ( SELECT TestID, Score, ROW_NUMBER() OVER (PARTITION BY Score ORDER BY SID) AS RowNumber FROM cteSource)SELECT p.RowNumber, p.[1], p.[2], p.[3], p.[4]FROM ctePresentation AS cPIVOT ( MAX(c.TestID) FOR Score IN ([1], [2], [3], [4]) ) AS p DROP TABLE #Scores I'm trying to show those Scores for a TestID that fall into each of the 4 score levels. The above code did not give the excpected results. Is NTILE the way to do it? Just very curious.Thanks. |