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;
| PName | MAX(UPrice) | MIN(UPrice) |
|---|---|---|
| Washing Powder | 120 | 120 |
| Toothpaste | 65 | 54 |
| Soap | 38 | 25 |
| Shampoo | 245 | 245 |
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
Step 1: Identify unique PName values: Washing Powder, Toothpaste, Soap, Shampoo
Step 2: For each PName, find MAX and MIN UPrice values from the table
Step 3: Washing Powder: MAX=120, MIN=120 (single row)
Step 4: Toothpaste: MAX=65, MIN=54 (rows with UPrice 54 and 65)
Step 5: Soap: MAX=38, MIN=25 (rows with UPrice 25 and 38)
Step 6: Shampoo: MAX=245, MIN=245 (single row)