Question 28 of 32intermediate🔧 ApplyVery Short1 mark

Write the output(s) produced by executing the following queries on the basis of the information given above in the table Product: SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP BY Pname;

Correct Answer
PNameMAX(UPrice)MIN(UPrice)
Washing Powder120120
Toothpaste6554
Soap3825
Shampoo245245
Exercise: EXERCISE | Q: 7(k) | (Page 49)
For More Understanding

Explanation

The query groups records by PName and calculates the maximum and minimum UPrice for each product name. Washing Powder and Shampoo have only one entry each, so MAX and MIN values are the same. Toothpaste has two entries (54 and 65), so MAX is 65 and MIN is 54. Soap has two entries (25 and 38), so MAX is 38 and MIN is 25.

Solution Steps

  1. Step 1: Identify unique PName values: Washing Powder, Toothpaste, Soap, Shampoo

  2. Step 2: For each PName, find MAX and MIN UPrice values from the table

  3. Step 3: Washing Powder: MAX=120, MIN=120 (single row)

  4. Step 4: Toothpaste: MAX=65, MIN=54 (rows with UPrice 54 and 65)

  5. Step 5: Soap: MAX=38, MIN=25 (rows with UPrice 25 and 38)

  6. Step 6: Shampoo: MAX=245, MIN=245 (single row)