All Exams Test series for 1 year @ ₹349 only
Question

Consider the following two tables named Raider and Team in a relational database maintained by a Kabaddi league. The attribute ID in table Team references the primary key of the Raider table, ID.

Raider
IDNameRaidsRaidPoints
1Arjun200250
2Ankush190219
3Sunil150200
4Reza150190
5Pratham175220
6Gopal193215
Team
CityIDBidPoints
Jaipur2200
Patna3195
Hyderabad5175
Jaipur1250
Patna4200
Jaipur6200

The SQL query described below is executed on this database: 

SELECT * 

FROM Raider, Team 

WHERE Raider.ID=Team.ID AND City="Jaipur" AND 

RaidPoints > 200; 

The number of rows returned by this query is ________.

SQL Query Analysis

The SQL query retrieves all columns ($*$) by joining the $Raider$ and $Team$ tables. The join condition is $Raider.ID = Team.ID$. It applies two filters: $Team.City = \text{"Jaipur"}$ and $Raider.RaidPoints > 200$.

Raider and Team Data

The query operates on the following two tables:

ID Name Raids RaidPoints
1 Arjun 200 250
2 Ankush 190 219
3 Sunil 150 200
4 Reza 150 190
5 Pratham 175 220
6 Gopal 193 215

City ID BidPoints
Jaipur 2 200
Patna 3 195
Hyderabad 5 175
Jaipur 1 250
Patna 4 200
Jaipur 6 200

Query Conditions Evaluation

We evaluate the query conditions to determine the number of matching rows:

1. Filter by City: Select rows from the $Team$ table where $Team.City = \text{"Jaipur"}$. The IDs of these teams are 1, 2, and 6.

2. Filter by RaidPoints: Select rows from the $Raider$ table where $Raider.RaidPoints > 200$. The IDs of raiders meeting this condition are 1 (RaidPoints=250), 2 (RaidPoints=219), 5 (RaidPoints=220), and 6 (RaidPoints=215).

3. Apply Join and Combined Filters: We need rows where the ID matches between the filtered $Team$ (IDs 1, 2, 6) and the filtered $Raider$ (IDs 1, 2, 5, 6). The common IDs that satisfy both city and raid points criteria are 1, 2, and 6.

  • ID 1: Team (City="Jaipur", ID=1) and Raider (ID=1, RaidPoints=250). Meets all conditions.
  • ID 2: Team (City="Jaipur", ID=2) and Raider (ID=2, RaidPoints=219). Meets all conditions.
  • ID 6: Team (City="Jaipur", ID=6) and Raider (ID=6, RaidPoints=215). Meets all conditions.

4. Count Matching Rows: There are 3 rows that satisfy all conditions.

The number of rows returned by the query is 3.

Was this answer helpful?

Important Questions from SQL

  1. Let Account be a relation as shown. 

                                                                                                             Account

    AccNoBalance
    A15000
    A25000
    A310000
    A415000
    A518000

    Consider the given SQL query.

    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)

  2. On a relation named Loan of a bank:
     

                             LOAN
    loan_numberbranch_nameamount
    L11Banjara Hills90000
    L14Kondapur50000
    L15SR Nagar40000
    L22SR Nagar25000
    L23Balanagar80000
    L25Kondapur70000
    L19SR Nagar65000


    the following SQL query is executed.
    SELECT L1.loan_number
    FROM Loan L1
    WHERE L1.amount > (SELECT MAX (L2.amount)
                                       FROM Loan L2
                                       WHERE L2.branch_name = 'SR Nagar');
    The number of rows returned by the query is ____________ (Answer in integer)

  3. Consider the following two commands C1 and C2 on the relation R from an SQL database :
    C1 : drop table R;
    C2 : delete from R;
    Which of the following statements is TRUE ?
    I. Both C1 and C2 delete the schema for R.
    II. C2 retains relation R, but deletes all tuples in R.
    III. C1 deletes not only all tuples of R, but also the schema for R.
  4. Which of the following is NOT a Structured Query Language Data type?

  5. Consider the following database tables of a sports league.

    player(pid,pname,age)         team(tid,tname,city,cid)
    coach(cid,cname)                  members(pid,tid)

    An instance of the table and an SQL query are given.

    Player

    pidpnameage
    1Jasprit31
    2Atharva24
    3Ishan26
    4Axar30

    Coach

    cidcname
    101Ricky
    102Mark
    103Trevor

    Team

    tidtnamecitycid
    10MIMumbai102
    20DCDelhi101
    30PKMohali103

    Members

    pidtid
    110
    230
    310
    420
    SELECT MIN(P.age)
    FROM player P
    WHERE P.pid IN (
     SELECT M.pid
     FROM team T, coach C, members M
     WHERE C.cname = 'Mark'
     AND T.cid = C.cid
     AND M.tid = T.tid
    );
    

    The value returned by the given SQL query is ______ . (Answer in integer)

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App