If you want to count the number of employees who have the same salary and have more than 3 employees with that salary, you can use the COUNT
, GROUP BY
, and HAVING
clauses together. Here's how you can write the SQL query:
SELECT Salary, COUNT(*) AS cnt FROM Employees GROUP BY Salary HAVING COUNT(*) > 3;
This query will count the number of employees for each unique salary value, and it will only include those salary values where the count of employees with that salary is greater than 3.
No comments:
Post a Comment