GATE DA 2026 | Question 60

Database Management and Warehousing › SQL · NAT · 2 marks · Answer: 3

  1. Question 60Database Management and Warehousingnat2 marks
    Let Account be a relation as shown.
    Account
    AccNo  Balance
    A1     5000
    A2     5000
    A3     10000
    A4     15000
    A5     18000
    Consider the given SQL query.
    sql
    SELECT AccNo FROM Account AS A WHERE (SELECT COUNT(*) FROM Account AS B WHERE A.Balance < B.Balance) >= (SELECT COUNT(*) FROM Account AS C WHERE A.Balance > C.Balance)
    The number of rows returned by the SQL query is __________ . (Answer in integer)

    Answer: 3

    Solution

    For each account, compare the number of higher balances with the number of lower balances:
    AccNo  Balance  higher  lower  higher >= lower?
    A1     5000     3       0      yes
    A2     5000     3       0      yes
    A3     10000    2       2      yes
    A4     15000    1       3      no
    A5     18000    0       4      no
    Three rows are returned. Answer: 3.

More GATE PYQ on SQL

All GATE DA Database Management and Warehousing PYQ →

Attempt GATE DA 2026 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →