Multiple counts in a single SQL query

jason

I have these three distinct queries :

SELECT COUNT(*)
  FROM [myDb].[dbo].[Properties] WHERE Bathtub is  null

SELECT COUNT(*)
  FROM [myDb].[dbo].[Properties] WHERE Bathroom is  null

SELECT COUNT(*)
  FROM [myDb].[dbo].[Properties] WHERE Toilet is  null

I want to see their counts in a single query. How can I do that? Thanks.

Kirk

Use Sub Queries! Learn some basics of SQL https://blog.sqlauthority.com/

SELECT 
(SELECT COUNT(*)
  FROM [myDb].[dbo].[Properties] WHERE Bathtub is  null) AS BathTub,

(SELECT COUNT(*)
  FROM [myDb].[dbo].[Properties] WHERE Bathroom is  null) AS Bathroom,

(SELECT COUNT(*)
  FROM [myDb].[dbo].[Properties] WHERE Toilet is  null) AS Toilet

Warning Overheads involved in case if you are worried about performance

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Multiple Counts with single query in mongodb

From Dev

MYSQL - Multiple counts in a single query

From Dev

multiple counts in single mysql query

From Dev

MYSQL - Multiple counts in a single query

From Java

How to get multiple counts with one SQL query?

From Dev

SQL Server Multiple Counts in the same Query

From Dev

create multiple counts in one SQL query

From Dev

Write custom SQL query for multiple counts

From Dev

consolidating multiple column counts into a single query with Rails 4 Activerecord

From Dev

Multiple counts in Sparql query

From Dev

mysql query (multiple counts)

From Dev

Multiple counts in Sparql query

From Dev

Creating an SQL query with multiple counts and different criteria from one table

From Dev

Linq to SQL to return multiple counts from query not returning correct results

From Dev

SQL Server - multiple counts in one query results issue

From Dev

Rails SQL Query counts

From Dev

Multiple counts on single grouped values

From Dev

Multiple counts on single grouped values

From Dev

SQL Server return multiple queries in a single query

From Dev

displaying multiple rows in single row in sql query

From Dev

SQL combining multiple select statements into a single query

From Dev

Multiple SQL statements in a single CakePHP query() call?

From Dev

PDO SQL single query, multiple rows and values

From Dev

SQL combining multiple select statements into a single query

From Dev

Sql query for multiple ANDs use in a single condition

From Dev

PL/SQL: Selecting multiple variables in a single query

From Dev

SQL Query to Transpose Column Counts to Row Counts

From Dev

Multiple months counts in one query

From Dev

multiple query report using counts

Related Related

HotTag

Archive