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. The result will be displayed under the alias 'count_of_buildings_with_email'.
SELECT COUNT(*) AS count_of_buildings_with_email
FROM buildings
WHERE email_address IS NOT NULL;
Here's the step by step explanation:
-
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. The result of this count is given the alias 'count_of_buildings_with_email'. -
FROM buildings: This part of the query specifies the table from which we want to select data, in this case, the 'buildings' table. -
WHERE email_address IS NOT NULL: This is the condition for the query. It tells the database to only count the rows where the 'email_address' column is not null, i.e., where there is an email address.
Similar Questions
Write a query to display the owner_name and mail id in which the string should end before the '@' symbol. Display the details of the buildings which are having the email address and give an alias name as 'email_name' and display it in ascending order based on owner name
Write a query to display the owner_name, address and contact_number of the buildings which does not have an email_address. Display the records in ascending order based on their owner_name.
Write a query to display the first 3 characters of the owner_name and the contact_number of all buildings in ascending order based on the owner name of the building. Give an alias to the first 3 characters as 'name_code'.
Write a query to display the number of the buildings who has given the fine amount.Give an alias name as 'building_count'.Note:1. Display only the number of buildings from the building table who has given the fine_amount. Use subqueries to achieve this.2. Tables involved are building, meter and bill.3. Specify the alias name without any mistake.4. Compare your executed result with the sample output given below.Note:1. Display only the number of the buildings who has given the fine amount from bill table.2. Specify the alias name without any mistake.3. Compare your executed result with the sample output given below.
Write a query to display the building owner name ,address and number of connections present in each building. Display the records in ascending order based on owner name.Give an alias name as connection_count.Note:1. Display only the building owner_name ,address and number of connections.2. Use Joins3. Tables involved building, building_type, meter4. Specify the alias name without any mistake.5. Order by is mandatory. 6. Compare your executed result with the sample output given below.
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.