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.
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.
Comments