Questions of SQL Training
Questions of SQL Training
select a.classname, avg(c.m1), avg(c.m2), avg(c.m3), from cm a join sm b on a.classcode = b.classcode join
marks c on b.rollno =c.rollno
4) Write a query to display student list from the given city whose name starts with the letter with ‘a’.
5) Write a query to display the list of classes and total collection of those classes for all those classes
whose collection more than 10 lakhs.
6) Write a query to display the list of student score more marks in m1 m2 and m3 in test 1 than the marks
scored by amol in test 1
Select a.rollno,a.name, b.classname, c.m1 from sm a join cm a.classcode = b.classcode join marks c on
a.rollno=c.rollno and c.testno=1and c.m1> (Select c.m1 from sm a join cm b on a.classcode=b.classcode join
a.rollno =c.rollno where a.name=’rahul’ and c.testno=1)
7) Write a query to display the average marks for those students whose avg mark is greater than the avg
marks of ‘fycse’ class
8) Write a query to display the list of female student from the city where ravi and roma stays.
Select rollno, name, gender, city from sm where gender=’f’ and city= any (select city from sm where
name=’ravi’ or name=‘roma’);
9) Write a query to display the list of students who have scored more marks in m1 then the average of his
class marks in m1
Select a.roll, a.name, b.classame, c.m1 from sm a join cm b on a.classcode=b.classcode join marks c on
a.rollno=c.rollno where c.m1> (select avg(c1.m1) from join a1 join cm b1 on a=classcode=b1.classcode join
marks c1 on a1.rollno=c.rollno where a1.classcode= a.classcode)