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

How do I create a view in db2?

0 Answers  


What is a base table?

2 Answers  


How do I import data from excel to db2?

0 Answers  


Cursors can be declared in both working-storage & procedure division, agreed. But is there any difference? If could you please suggest what is the difference

0 Answers  


wht steps we need will coding cobol and db2 pgm ?

6 Answers   CGI,






select distinct(empid),distinct(dept),name from EMP will the above query work?

2 Answers   CTS,


When is the skeleton cursor table created?

1 Answers  


How can deadlocks be resolved?

0 Answers  


How do you declare a host variable (in COBOL) for an attribute named emp-name of type VARCHAR(25) ?

2 Answers   IBM, Tech Mahindra,


How to retrieve rows from a db2 table in embedded sql?

0 Answers  


how can i pull up a query which was previously stored in qmf

3 Answers  


What is the latest version of ibm db2?

0 Answers  


Categories