SI Stud name Subject Marks Pass/Fail
1 Sham Maths 40 P
1 Sham Physics 50 P
1 Sham Bio 20 F
2 Ram Maths 40 P
2 Ram Physics 50 P
2 Ram Bio 60 P

For the above data , write the SQL query for the student who passed in all the subjects . For eg : I want the data of only Ram coz he passed all subjects .

Answer Posted / ajmal

SELECT *
FROM STUDENT_TABLE
WHERE SI NOT IN
(SELECT DISTINCT SI
FROM STUDENT_TABLE
WHERE PASS_FAIL = 'F'
)


The inner query will retrieve all the SI numbers for who is failed in at least 1 subject(eg: Sham). The outer query will retrieve the other student's details(eg: Ram).

Is This Answer Correct ?    19 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is scrollable cursor in db2?

690


Describe major components of db2?

742


What is a Foreign Key?

744


What is the syntax for creating a table in the db2 database?

720


What do you mean by cursor?

684






How connect db2 database to datastage?

866


Define db2 and its databases?

708


What is runstats and reorg in db2?

905


What is db2 connect?

691


What happens in bind step in a db2 program?

649


What is the use of with ur in db2?

704


How can tablespace be moved to another dasd volume that is allocated for that tablespace?

852


List some fields from sqlca?

682


What is a bind in db2?

680


What is null value in db2?

653