GATE CS 2020 · Question 23 · Databases · Multiple choice (MCQ) · 1 mark · −1/3 for a wrong answer
Consider a relational database containing the following schemas.
Catalogue
Suppliers
Parts
The primary key of each table is indicated by underlining the constituent fields.
SELECT s.sno, s.sname FROM Suppliers s, Catalogue c WHERE s.sno = c.sno AND cost > (SELECT AVG (cost) FROM Catalogue WHERE pno = 'P4' GROUP BY pno);
The number of rows returned by the above SQL query is
| sno | pno | cost |
|---|---|---|
| S1 | P1 | 150 |
| S1 | P2 | 50 |
| S1 | P3 | 100 |
| S2 | P4 | 200 |
| S2 | P5 | 250 |
| S3 | P1 | 250 |
| S3 | P2 | 150 |
| S3 | P5 | 300 |
| S3 | P4 | 250 |
| sno | sname | location |
|---|---|---|
| S1 | M/s Royal furniture | Delhi |
| S2 | M/s Balaji furniture | Bangalore |
| S3 | M/s Premium furniture | Chennai |
| pno | pname | part_spec |
|---|---|---|
| P1 | Table | Wood |
| P2 | Chair | Wood |
| P3 | Table | Steel |
| P4 | Almirah | Steel |
| P5 | Almirah | Wood |
- (A) 4
- (B) 5
- (C) 0
- (D) 2
Answer
Answer (A)
Answer from the official GATE CS 2020 answer key.
The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes