Mysql Adv Notes-2
Mysql Adv Notes-2
(1,60,85,90),
(2,21,29,94),
(3,100,85,18),
(4,95,52,64),
(5,45,56,72),
(6,25,23,57),
(7,40,55,92),
(8,56,74,80),
(9,47,55,93),
(10,30,35,70),
(11,88,77,66),
(12,85,77,44),
(13,65,45,21),
(14,50,55,60),
(15,80,55,40),
(16,78,95,80),
(17,98,23,40),
(18,90,85,70),
(19,70,33,70),
(20,50,65,90),
(21,90,75,90),
(22,80,35,50),
(23,90,95,98),
(24,80,85,90);
Here we are going to join CNAME column from course table into students table with the help of join
query.
11. select students.name,students.rollno,students.cid from students;
ROUND
16. SELECT students.name,students.rollno,course.cname,marks.M1,marks.M2,marks.M3,
(marks.M1+marks.M2+marks.M3) As Total_Marks,
FIND RESULT
round((marks.M1+marks.M2+marks.M3)/3,2) As Average ,
case
else 'FAIL'
end
as Result
FROM students
round((marks.M1+marks.M2+marks.M3)/3,2) As Average ,
case
else 'FAIL'
end
as Result ,
case
case
else 'Grade-C'
end
end as Grade
FROM students
where course.cname='AIDS'; ( just add this query at the end queries in above)
where course.cname='AIDS' and Result='PASS'; ( just add this query in the above example)
( here leads error like “Error Code: 1054. Unknown column 'Result' in 'where clause')
VIEW
19. CREATE VIEW Reports AS ( just add this line at the beginning of your query)
SELECT students.name,students.rollno,course.cname,marks.M1,marks.M2,marks.M3,
(marks.M1+marks.M2+marks.M3) As Total_Marks,
round((marks.M1+marks.M2+marks.M3)/3,2) As Average ,
case
else 'FAIL'
end
as Result ,
case
case
end
end as Grade
FROM students