Skip to content
Question 88 of 95

Q.(a) Consider the following tables Student and Sport : Table : Student ADMNO NAME CLASS 1100 MEENA X 1101 VANI XI Table : Sport ADMNO GAME 1100 CRICKET 1103 FOOTBALL What will be the output of the following statement ? SELECT * FROM Student, Sport;

(b) Write the output of the queries
(i) to
(iv) based on the table, GARMENT given below : TABLE : GARMENT GCODE TYPE PRICE FCODE ODR_DATE G101 EVENING GOWN 850 F03 2008-12-19 G102 SLACKS 750 F02 2020-10-20 G103 FROCK 1000 F01 2021-09-09 G104 TULIP SKIRT 1550 F01 2021-08-10 G105 BABY TOP 1500 F02 2020-03-31 G106 FORMAL PANT 1250 F01 2019-01-06
(i) SELECT DISTINCT(COUNT(FCODE)) FROM GARMENT;
(ii) SELECT FCODE, COUNT(), MIN(PRICE) FROM GARMENT GROUP BY FCODE HAVING COUNT()>1;
(iii) SELECT TYPE FROM GARMENT WHERE ODR_DATE >'2021-02-01' AND PRICE <1500;
(iv) SELECT * FROM GARMENT WHERE TYPE LIKE 'F%';
Rajasthan RbseCBSE Class XII Board 2023Subjective· 3mImportance★★★★★
93% · 88/95 Questions
🔒 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 →

The first query produces a Cartesian product (every row of Student paired with every row of Sport), while the second set of queries tests your understanding of aggregate functions, GROUP BY, HAVING, date comparisons, and pattern matching in SQL.

(a) The Cartesian Product

The statement SELECT * FROM Student, Sport; is a cross join — it combines every row from the first table with every row from the second table. This is called a Cartesian product.

Student has two rows (ADMNO 1100 and 1101). Sport also has two rows (ADMNO 1100 and 1103). So the output will have 2 × 2 = 4 rows. Each row of Student is paired with each row of Sport, regardless of whether the ADMNO values match.

The result will look like this:

ADMNONAMECLASSADMNOGAME
1100MEENAX1100CRICKET
1100MEENAX1103FOOTBALL
1101VANIXI1100CRICKET
1101VANIXI1103FOOTBALL

Notice that the ADMNO column appears twice — once from each table. This is rarely useful in practice; you would normally add a WHERE clause to match related rows.

Important

A Cartesian product multiplies every row of one table with every row of another. If Student had 100 rows and Sport had 50, the output would be 5000 rows — often unintended and computationally expensive.


(b) Queries on the GARMENT table

Let us examine each query one by one.

(i) SELECT DISTINCT(COUNT(FCODE)) FROM GARMENT;

This query first counts the number of non-null FCODE values in the entire table. There are 6 rows, and every row has an FCODE, so COUNT(FCODE) returns 6. That single number (6) is then passed to DISTINCT. Since there is only one value, the output is simply:

COUNT(FCODE)
6
Note

DISTINCT here is redundant — it applies to the single aggregated value. The parentheses around COUNT(FCODE) are also unnecessary; DISTINCT COUNT(FCODE) would work the same way.

(ii) SELECT FCODE, COUNT(*), MIN(PRICE) FROM GARMENT GROUP BY FCODE HAVING COUNT(*)>1;

This groups rows by FCODE. Let us see how many rows each FCODE has:

  • F01: G103 (FROCK), G104 (TULIP SKIRT), G106 (FORMAL PANT) → 3 rows
  • F02: G102 (SLACKS), G105 (BABY TOP) → 2 rows
  • F03: G101 (EVENING GOWN) → 1 row

The HAVING COUNT(*)>1 keeps only groups with more than one row — so F03 is dropped. For the remaining groups, the query selects the FCODE, the count of rows, and the minimum price in that group.

For F01: minimum price among 1000, 1550, 1250 is 1000.

For F02: minimum price among 750, 1500 is 750.

Output:

FCODECOUNT(*)MIN(PRICE)
F0131000
F022750

(iii) SELECT TYPE FROM GARMENT WHERE ODR_DATE >'2021-02-01' AND PRICE <1500;

This filters rows where the order date is after 1 February 2021 AND the price is less than 1500. Let us check each row:

  • G101: date 2008-12-19 — before 2021, so fails.
  • G102: date 2020-10-20 — before 2021, fails. …

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.