CBSE Class 12 Informatics Practices
Question 64 of 90
Querying Using SQL — Question 4
Back to all questions 4
Question Table SALES
| Column Name |
|---|
| STORE_ID |
| SALES_DATE |
| SALES_AMOUNT |
Which SQL statement lets you find the total number of stores in the SALES table?
- SELECT COUNT(STORE_ID) FROM SALES;
- SELECT COUNT(DISTINCT STORE_ID) FROM SALES;
- SELECT DISTINCT STORE_ID FROM SALES;
- SELECT COUNT(STORE_ID) FROM SALES GROUP BY STORE_ID;
SELECT COUNT(DISTINCT STORE_ID) FROM SALES;SELECT COUNT(STORE_ID) FROM SALES;— This query uses the COUNT() aggregate function with the STORE_ID column in the SELECT statement. It counts the number of non-null values in the STORE_ID column, and this count includes duplicates.SELECT COUNT(DISTINCT STORE_ID) FROM SALES;— This option uses COUNT(DISTINCT STORE_ID) to count the number of unique store IDs in the SALES table. The DISTINCT keyword ensures that only distinct (unique) values are counted, avoiding overcounting due to duplicates.SELECT DISTINCT STORE_ID FROM SALES;— This option selects distinct (unique) store IDs from the SALES table but does not count or provide the total number of stores.SELECT COUNT(STORE_ID) FROM SALES GROUP BY STORE_ID;— This option attempts to count the number of occurrences of each store ID by using COUNT(STORE_ID) and grouping by store ID with GROUP BY STORE_ID. However, this results in a count for each unique store ID separately, not the total number of stores in the table.