SQL questions

Q23

GATE CS 2017 CS-1Relational QueriesNAT1 mark
Consider a database that has the relation schema EMP(EmpId, EmpName, and DeptName). An instance of the schema EMP and a SQL query on it are given below.
EmpIdEmpNameDeptName
1XYAAA
2XYBAA
3XYCAA
4XYDAA
5XYEAB
6XYFAB
7XYGAB
8XYHAC
9XYIAC
10XYJAC
11XYKAD
12XYLAD
13XYMAE
SELECT AVG(EC.Num)
FROM EC
WHERE (DeptName, Num) IN
    (SELECT DeptName, COUNT(EmpId) AS
                    EC(DeptName, Num)
     FROM EMP
     GROUP BY DeptName)
The output of executing the SQL query is ____________.
Show answer without attempting

Answer: 2.6

Q46

GATE CS 2017 CS-2Relational QueriesNAT2 marks
Consider the following database table named top_scorer.
playercountrygoals
KloseGermany16
RonaldoBrazil15
G MüllerGermany14
FontaineFrance13
PeléBrazil12
KlinsmannGermany11
KocsisHungary11
BatistutaArgentina10
CubillasPeru10
LatoPoland10
LinekerEngland10
T MüllerGermany10
RahnGermany10
Consider the following SQL query:
SELECT ta.player FROM top_scorer AS ta
WHERE ta.goals > ALL (SELECT tb.goals
                        FROM top_scorer AS tb
                        WHERE tb.country = 'Spain')
AND ta.goals > ANY (SELECT tc.goals
                    FROM top_scorer AS tc
                    WHERE tc.country = 'Germany')
The number of tuples returned by the above SQL query is ____________.
Show answer without attempting

Answer: 7.0

0/20 correct0 marks

Related topics in Relational Queries