Knowee
Questions
Features
Study Tools

Write a query to display the number of bills having fine_amount. Give an alias name as 'count_of_bills_with_fine'.

Question

Write a query to display the number of bills having fine_amount. Give an alias name as 'count_of_bills_with_fine'.

🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a SQL query that will count the number of bills that have a fine amount. The result will be displayed under the alias 'count_of_bills_with_fine'.

SELECT COUNT(*) AS count_of_bills_with_fine
FROM bills
WHERE fine_amount IS NOT NULL;

Here's the step by step explanation:

  1. SELECT COUNT(*) AS count_of_bills_with_fine: This part of the query is used to count the number of rows in the result set. The AS keyword is used to give the result an alias name, which in this case is 'count_of_bills_with_fine'.

  2. FROM bills: This part of the query specifies the table from which to retrieve the data, which in this case is the 'bills' table.

  3. WHERE fine_amount IS NOT NULL: This part of the query is a condition that filters the results to only include rows where the 'fine_amount' is not null, meaning there is a fine amount.

Please replace 'bills' and 'fine_amount' with your actual table name and column name.

This problem has been solved

Similar Questions

Write a query to display the sum of payable_amount and fine_amount of all the bills from bill table. Give an alias name to the sum of payable amount and fine amount as 'sum_payable_and_fine_amount'.

Write a query to display the number of bills in which the bill payment is completed. Give an alias name as 'count_of_bills_with_payment'.Note:1. Display only the number of bills where payment is completed.(If payment is completed then is_payed will be 1, otherwise 0.)2. Specify the alias name without any mistake.3. Specify condition on is_payed column from bill table.4. Compare your executed result with the sample output given below.

Write a query to display the count of bills which has completed payment without fine on the month of October 2017. Give an alias name as 'bills_paid_withoutfine'.Note:1. Display only the count of bills which has completed payment without fine on the month of October 2017 from bill table.2. Specify the alias name without any mistake.3. Specify condition on payment_date and fine_amount. payment_date must be NOT NULL and it must be October 2017 and fine_amount must be NULL.4. Compare your executed result with the sample output given below.Sample output:

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

1/3

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.