Explain why the two following commands produce different res

Explain why the two following commands produce different results. SELECT DISTINCT COUNT (V_CODE) FROM PRODUCT; SELECT COUNT (DISTINCT V_CODE) FROM PRODUCT;

Solution

Please follow the data and description :

Given, Query is

SELECT DISTINCT COUNT (V_CODE) FROM PRODUCT;
SELECT COUNT (DISTINCT V_CODE) FROM PRODUCT;

As it is clearly visible the major difference is in the order of operations of the queries. The first command executes the Count function so as to count the number of values/data in the V_CODE. For example, let us assume that the count that returns be \"16\" which is including the duplicate values, and then the Distinct keyword only allows one count of that value to be displayed more clearly only one row with the value \"16\" appears as the result. Now in the second command the code applies the Distinct keyword to the V_CODEs before the count is taken so only the respective unique values are only counted.


Hope this is helpful.

Explain why the two following commands produce different results. SELECT DISTINCT COUNT (V_CODE) FROM PRODUCT; SELECT COUNT (DISTINCT V_CODE) FROM PRODUCT;Solut

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site