How to use distinct and count in SQL query? Explain
count(): It returns the number of rows in a table satisfying the condition specified in the WHERE clause. It would return 0 if there were no matching conditions.
SELECT COUNT(*) FROM category WHERE 'status' = 1;
distinct(): It is used to return only different values. In a table, a column often contains many duplicate values, and sometimes we want to list the different values. It can be used with aggregates functions.
SELECT DISTINCT class FROM College ORDER BY department
This information was frequently asked during SQL interview questions for testers.
BY Best Interview Question ON 31 Jan 2019