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
What is scrollable cursor in db2?
Describe major components of db2?
What is a Foreign Key?
What is the syntax for creating a table in the db2 database?
What do you mean by cursor?
How connect db2 database to datastage?
Define db2 and its databases?
What is runstats and reorg in db2?
What is db2 connect?
What happens in bind step in a db2 program?
What is the use of with ur in db2?
How can tablespace be moved to another dasd volume that is allocated for that tablespace?
List some fields from sqlca?
What is a bind in db2?
What is null value in db2?