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

Explain what are the various isolation levels possible?

610


Explain about dbrm.

609


can any one provide me the link for the db2 v7 & db2 v8 manual for Z/os? i need to know about the syntax of REORG in both versions & need to know the difference as well

1806


How does cobol compile db2 program?

608


What is dclgen (declaration generator)?

603






How can you do the explain of a dynamic sql statement?

637


How to find the maximum value in a column in the db2 database?

611


What is the maximum size of varchar data type in db2?

645


How can you classify the locks in db2?

636


How to take backup of table in db2?

601


What is a system catalog table in db2?

588


Mention data types used in db2 ?

679


Explain about cursor stability?

621


What type of database is db2?

523


List out the data types available.

704