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
Where do you specify them?
What is netezza database?
How can you count the number of rows from a table tab?
What is sqlca’s maximum length?
What is dbrm in db2 database?
Define db2 and its databases?
What happens in bind step in a db2 program?
What is the reason behind not using select * in embedded sql programs?
What is a trigger in the db2 database?
How do you find the maximum value in a column in db2?
How to fetch the last row from the table in SQL (db2)?
Explain about mirror activator disk mirroring?
How does a cursor work?
What is db2 stogroup?
How do you simulate the explain of an embedded sql statement in spufi/qmf?