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

If the main program has only cobol statements and subprogram has the db2 statements what is the procedure for precompilation. for which program we need to do the precompilation

1 Answers   IBM,


How do you simulate the EXPLAIN of an embedded SQL statement in SPUFI/QMF? Give an example with a host variable in WHERE clause)

2 Answers  


what is the use of commit ? and what is the syntax?

2 Answers   Deloitte,


What is the default page size of buffer pools?

0 Answers  


Where could you look if you had a question about whether a column has been defined as an index?

2 Answers  






What is a collection?

3 Answers  


wht is d/f between union and joins ?

2 Answers  


What is reorg in database?

1 Answers  


What is the use of dclgen in db2?

0 Answers  


What is a synonym ?

2 Answers  


Say CUST Table contains records like: CUSTNO CUSTNAME CUSTLOC 100 ABC SSS 200 XYZ 300 PQR 400 MNO WWW 500 CVV ------------- ------------- Now write a query to retrieve all records with CUSTLOC no data.

3 Answers   IBM,


Suppose pgm A calling Pgm B .Pgm B has some Db2 program. at the time of compilation should plan and package will be created for both A and B or only B? What is the concept?

2 Answers  


Categories