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 .

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / guest

Select Stud_name
From Student_Table
Where Pass_Fail = P
Group by SI

Is This Answer Correct ?    6 Yes 19 No

Post New Answer

More DB2 Interview Questions

What will the COMMIT accomplish?

5 Answers  


What techniques will be used to avoid deadlock??

5 Answers   IBM, SUN,


Why use RUNSTAT Utility?

3 Answers   Merrill Lynch,


What is a view? Why use it?

3 Answers  


What is the purpose of using commit?

0 Answers  






What are sqlcodes –803,-805, -811, -818,-904,-911,-913,-101, +100?

0 Answers  


What is the physical storage length of time data type?

0 Answers  


What does runstats do in db2?

0 Answers  


What does reorg do in db2?

0 Answers  


What are the three types of page locks that can be held?

1 Answers  


What are the uses of db2 optimizer?

0 Answers  


How can you compare table column after update and before update?

5 Answers   Satyam,


Categories