计数问题()

cha*_*ara 2 sql-server sql-server-2005

我想编写一个查询中检索COUNT(of employees with the salary=1000)COUNT(of total no of employees)从同一个表.有任何想法吗??

Tom*_*m H 5

另一种方法:

SELECT
    COUNT(*) AS total_employees,
    SUM(CASE WHEN salary = 1000 THEN 1 ELSE 0 END) AS employees_with_1000_salary
FROM
    Employees
Run Code Online (Sandbox Code Playgroud)