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 table: ID | Name | Raido | RaidPoints 1 | Arnav | 250 | 219 2 | Ankush | 190 | 219 3 | Mohan | 150 | 200 4 | Rosa | 150 | 190 5 | Prathan | 175 | 220 6 | Gopal | 100 | 215 Team table: City | ID | BidPoints Jaipur | 1 | 200 Patna | 3 | 195 Hyderabad | 5 | 175 Patna | 4 | 200 Jaipur | 6 | 200 The following SQL query is executed on this database: SELECT * FROM Raider, Team WHERE Raider.ID = Team.ID AND City = 'Jaipur' AND BidPoints >= 200; The number of rows returned by the query is _______ (Answer in integer).

GATE 2024 · Databases · SQL · medium

Answer: The number of rows returned by the query is 2.

  1. Perform equi-join on Raider.ID = Team.ID: Team has IDs: 1, 3, 4, 5, 6. So the joined result has 5 rows: (1, Arnav, 250, 219, Jaipur, 1, 200) (3, Mohan, 150, 200, Patna, 3, 195) (4, Rosa, 150, 190, Patna, 4, 200) (5, Prathan, 175, 220, Hyderabad, 5, 175) (6, Gopal, 100, 215, Jaipur, 6, 200)
  2. Apply WHERE filter: City = 'Jaipur' AND BidPoints >= 200: Check each joined row: - ID=1: City=Jaipur ✓, BidPoints=200 >= 200 ✓ → included - ID=3: City=Patna ✗ → excluded - ID=4: City=Patna ✗ → excluded - ID=5: City=Hyderabad ✗ → excluded - ID=6: City=Jaipur ✓, BidPoints=200 >= 200 ✓ → included Rows passing: 2