Skip to content
Question
Q.

Consider the following tables PARTICIPANT and ACTIVITY :

Table : PARTICIPANT

ADMNONAMEHOUSEACTIVITYCODE
6473Kapil ShahGandhiA105
7134Joy MathewBoseA101
8786Saba AroraGandhiA102
6477Kapil ShahBoseA101
7658Faizal AhmedBhagatA104

Table : ACTIVITY

ACTIVITYCODEACTIVITYNAMEPOINTS
A101Running200
A102Hopping bag300
A103Skipping200
A104Bean bag250
A105Obstacle350

Write command in SQL for the following : (i) To display Activity Code along with number of participants participating in each activity (Activity Code wise) from the table Participant. OR How many rows will be there in Cartesian product of the two tables in consideration here ?

CBSECBSE Class XII Board 2019Subjective· 2mImportance★★★★★
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Part (a): GROUP BY ACTIVITYCODE with COUNT(*) — A101 = 2, A102/A104/A105 = 1 each.

Part (b): Cartesian product = 5 rows x 5 rows = 25 rows.

Part (a) — participants per activity

To show how many participants chose each activity, group the PARTICIPANT rows by ACTIVITYCODE and count each group:

SELECT ACTIVITYCODE, COUNT(*) FROM PARTICIPANT GROUP BY ACTIVITYCODE;

GROUP BY collapses rows sharing the same ACTIVITYCODE into one group; COUNT(*) tallies each group. From the data, A101 is chosen by two participants (Joy Mathew and the second Kapil Shah), while A102, A104 and A105 are chosen by one each:

ACTIVITYCODE   COUNT(*)
A101           2
A102           1
A104           1
A105           1
``` …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.