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.Sample Output:
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.Sample Output:
Solution
The query you're looking for would look something like this:
SELECT COUNT(*) AS count_of_buildings_with_email
FROM building
WHERE email_address IS NOT NULL;
Here's a step-by-step breakdown of this SQL query:
-
SELECT COUNT(*) AS count_of_buildings_with_email: This part of the query is telling the database to count the number of rows and to label this count as 'count_of_buildings_with_email'. TheCOUNT(*)function counts the number of rows in a table. -
FROM building: This part of the query specifies the table we are selecting data from, which in this case is the 'building' table. -
WHERE email_address IS NOT NULL: This is the condition for the query. It's telling the database to only count the rows where the 'email_address' column is not null, i.e., where there is an email address.
When you run this query, it will return the number of buildings in the 'building' table 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.
Write a query to display the number of bills from the bill table which are payed for the building with connection_type 'Commercial'. Give an alias name as 'payment_count'.Note:1. Display only the number of bills from the bill table which are payed(is_payed=1) for the building with connection_type 'Commercial'.2. Tables involves are bill, meter, building, building_type and electricity_connection_type.3. Specify the alias name without any mistake.4. 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.