0% found this document useful (0 votes)
38 views

MySQL Statement Grades SQL

This SQL statement selects student grade data from two databases and aggregates the results to summarize the number of grades by course, branch, and batch. It counts the number of students who received each letter grade (U, E, D, C, etc.), the total number of results, and the number of unique students. The results are grouped by branch and batch year to provide grade statistics for different course offerings.

Uploaded by

webbiz
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

MySQL Statement Grades SQL

This SQL statement selects student grade data from two databases and aggregates the results to summarize the number of grades by course, branch, and batch. It counts the number of students who received each letter grade (U, E, D, C, etc.), the total number of results, and the number of unique students. The results are grouped by branch and batch year to provide grade statistics for different course offerings.

Uploaded by

webbiz
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

C:\MySQL_Statement_Grades.

sql

Sunday, March 02, 2014 10:52 PM

SELECT
b.CourseID
, b.Branch
, CONCAT('20',MID(a.RegNo,LENGTH(a.RegNo)-7,2)) AS Batch
, CONCAT('20',MID(a.RegNo,LENGTH(a.RegNo)-7,2), ' ', b.Branch) AS BatchBranch
, SUM(IF(Grade='U',1,0)) AS U
, SUM(IF(Grade='E',1,0)) AS E
, SUM(IF(Grade='D',1,0)) AS D
, SUM(IF(Grade='C',1,0)) AS C
, SUM(IF(Grade='B',1,0)) AS B
, SUM(IF(Grade='A',1,0)) AS A
, SUM(IF(Grade='S',1,0)) AS S
, SUM(IF(Grade IN ('S','A','B','C','D','E','U'),1,0)) AS Results
, SUM(IF(Grade NOT IN ('S','A','B','C','D','E','U'),1,0)) AS Others
, COUNT(*) AS AllResults
, COUNT(DISTINCT c.RegNo) AS Students
FROM au_results.augrades a LEFT JOIN scaddata.courses b ON (b.CourseID = MID(a.RegNo,LENGTH(a
.RegNo)-5,3))
LEFT JOIN aunames c USING (RegNo)
GROUP BY Branch, Batch;

-1-

You might also like