Consider the following table named “Product”, showing details of products being sold in a grocery shop.
PCode PName UPrice P01 SOAP 200 P02 SHAMPOO NULL P03 COMP 50
Write the output produced by the following SQL command:
SELECT COUNT(UPrice) FROM Product;
Consider the following table named “Product”, showing details of products being sold in a grocery shop.
| PCode | PName | UPrice |
|---|---|---|
| P01 | SOAP | 200 |
| P02 | SHAMPOO | NULL |
| P03 | COMP | 50 |
Write the output produced by the following SQL command:
SELECT COUNT(UPrice) FROM Product;
Solution
✅ Correct Option: 3
COUNT(column) counts only the non-NULL values in that column. UPrice has values 200, NULL and 50, so only 200 and 50 are counted, giving 2.
Option 1: 3 is what COUNT(*) would return, because it counts all rows including those with NULL.
Related questions:
2026: 19 May Shift 1
2026: 24 May Shift 1
2025: 14 May Shift 1