What's the difference between these two clauses in SQL?
The two clauses are:
SELECT DISTINCT COUNT (V_CODE) FROM PRODUCT;
SELECT COUNT (DISTINCT V_CODE) FROM PRODUCT;
- TheMadProfessorLv 78 years agoFavorite Answer
In the first, DISTINCT serves no purpose - the COUNT will only return a single value in any case, so it'd be distinct by default. The result will be the number of rows in PRODUCT.
In the second, the DISTINCT V_CODE result is a collection of the unique values of V_CODE within table PRODUCT. The COUNT will then result in the number of those unique values, which will be some value less than or equal to that of the first query.