Write a query to display the number of buildings having an email_address. Give an alias name as 'count_of_buildings_with_email'.
Question
Write a query to display the number of buildings having an email_address.
Give an alias name as count_of_buildings_with_email
.
Solution
Sure, here is a SQL query that will give you the number of buildings that have an email address. I'm assuming that your table name is 'buildings' and the column for email addresses is 'email_address'.
SELECT COUNT(*) AS count_of_buildings_with_email
FROM buildings
WHERE email_address IS NOT NULL;
Here's a step-by-step breakdown of the query:
-
SELECT COUNT(*) AS count_of_buildings_with_email
: This part of the query is used to count the number of rows in the 'buildings' table where the 'email_address' is not null. TheAS
keyword is used to give this count a name, or alias, 'count_of_buildings_with_email'. -
FROM buildings
: This part of the query specifies the table we are selecting data from, which is the 'buildings' table. -
WHERE email_address IS NOT NULL
: This is the condition for the query. It only counts the rows where the 'email_address' column is not null, meaning there is an email address for the building.
Similar Questions
Write a query to display all the details of the 'building' whose owner_name is 'Nicholas'.
Write a query to delete the details of the building whose owner got an email_address '[email protected]'.
Write a query to display the number of electricity_reading in which the total_units per day is greater than 500. Give an alias name as 'count_total_units_500'.
Write a query to display all the building details in which building_type named ‘Library’. Display the records in ascending order based on their owner_name
Write a query to display the number of bills having fine_amount. Give an alias name as 'count_of_bills_with_fine'.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.