Я хочу написать запрос для получения COUNT(of employees with the salary=1000) и COUNT(of total no of employees) из той же таблицы.есть идеи ??
COUNT(of employees with the salary=1000)
COUNT(of total no of employees)
Другой метод:
SELECT COUNT(*) AS total_employees, SUM(CASE WHEN salary = 1000 THEN 1 ELSE 0 END) AS employees_with_1000_salary FROM Employees
SELECT COUNT(EmployeeID) as 'Total Employees', (SELECT COUNT(EmployeeID) FROM Employees WHERE Salary = 1000) as 'Salaried' FROM Employees
select count(*) totalCount, count(case when salary = 1000 then 1 else NULL end) specialCount from Employees
COUNT считает ненулевые строки.
select count(*) as employeeCount, (select count(*) from employee where salary=1000) as bigmoneyEmployeeCount from employee