Use SUM/CASE…
SELECT
COUNT(*), --total
SUM(CASE WHEN name="system" THEN 1 ELSE 0 END) --conditional
FROM
myTable
More Related Contents:
- SQL where clause odd behavior [closed]
- How do I escape a single quote in SQL Server?
- Simple way to transpose columns and rows in SQL?
- Only inserting a row if it’s not already there
- Unpivot with column name
- Selecting data from two different servers in SQL Server
- Maximum size for a SQL Server Query? IN clause? Is there a Better Approach [duplicate]
- SQL JOIN vs IN performance?
- Most efficient way in SQL Server to get date from date+time?
- Convert varchar into datetime in SQL Server
- TSQL Pivot without aggregate function
- How to generate a range of dates in SQL Server
- SQL RANK() versus ROW_NUMBER()
- How to rewrite IS DISTINCT FROM and IS NOT DISTINCT FROM in SQL Server 20008R2?
- SQL : BETWEEN vs =
- Drop all the tables, stored procedures, triggers, constraints and all the dependencies in one sql statement
- How do I perform a GROUP BY on an aliased column in SQL Server?
- How do I make a composite key with SQL Server Management Studio?
- Is it possible to perform multiple updates with a single UPDATE SQL statement?
- Incorrect syntax near the keyword ‘with’…previous statement must be terminated with a semicolon
- Alter user defined type in SQL Server
- Best equivalent for IsInteger in SQL Server
- Store multiple bit values in a single table column
- Syntax of for-loop in SQL Server
- SQL Server equivalent to MySQL enum data type?
- SQL – Call Stored Procedure for each record
- SQL – How do I get only the numbers after the decimal?
- How to retrieve records for last 30 minutes in MS SQL?
- Group consecutive rows of same value using time spans
- Why do SQL Server Scalar-valued functions get slower?