Write a query to display the number of buildings having an email_address. Give an alias name as 'count_of_buildings_with_email'.Note:1. Display only the count of buildings having an email_address from building table.2. Specify the alias name without any mistake.3. Specify condition and retrieve the correct number of rows.(condition need to be specified on email_address column. If email_address is not null then it must be counted)3. Compare your executed result with the sample output given below.
Question
Write a query to display the number of buildings having an email_address. Give an alias name as 'count_of_buildings_with_email'.Note:1. Display only the count of buildings having an email_address from building table.2. Specify the alias name without any mistake.3. Specify condition and retrieve the correct number of rows.(condition need to be specified on email_address column. If email_address is not null then it must be counted)3. Compare your executed result with the sample output given below.
Solution 1
Here is the SQL query you need to write to get the desired result:
SELECT COUNT(email_address) AS count_of_buildings_with_email
FROM building
WHERE email_address IS NOT NULL;
Let's break it down:
-
SELECT COUNT(email_address) AS count_of_buildings_with_email: This part of the query is selecting the count ofemail_addressand giving it an alias namecount_of_buildings_with_email. -
FROM building: This part is specifying the table from which we want to select data, which is thebuildingtable. -
WHERE email_address IS NOT NULL: This is the condition that needs to be met. We only want to count the buildings whereemail_addressis not null.
After running this query, you will get the count of buildings that have an email address.
Solution 2
Here is the SQL query you need to write to get the desired result:
SELECT COUNT(email_address) AS count_of_buildings_with_email
FROM building
WHERE email_address IS NOT NULL;
Let's break it down:
-
SELECT COUNT(email_address) AS count_of_buildings_with_email: This part of the query is used to count the number of rows where theemail_addressis not null. TheASkeyword is used to give this count a name, or alias, which iscount_of_buildings_with_email. -
FROM building: This part of the query specifies the table we are selecting data from, which is thebuildingtable. -
WHERE email_address IS NOT NULL: This is the condition that must be met for a row to be included in the count. It checks if theemail_addresscolumn is not null, meaning that there is an email address for the building.
After running this query, you will get the count of buildings that have an email address.
Similar Questions
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 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.Note:1. Display only the columns owner_name, address and contact_number present in the building table.2. Specify the condition and retrieve the correct rows in the result(condition need to be specified on email_address column. If email_address is NULL, then it indicates email_address does not present).3. You can compare your executed result with the sample output given below.4. Order by is mandatorySample output: [Only few records are shown here]
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.Note:1. Display only the owner name and mail id in which the string ends before the @ from building table.2. Specify the alias name without any mistake.3. Order by is mandatory4. Use SUBSTR function5. Compare your executed result with the sample output given below.Sample output:[only few records shown here]
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.
QueryQ14Write 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.
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.