Write a query to display the average fine_amount of the bills whose payment_date is on the year 2018. Give an alias name to the average fine amount as 'average_fine_amount'.Note:1. Display only the average fine_amount with the given payment_date from bill table.2. Specify the alias name without any mistake.3.Specify the condition and retrieve the correct rows in the result(condition need to be specified on fine amount).4. Compare your executed result with the sample output given below.Sample output:
Question
Write a query to display the average fine_amount of the bills whose payment_date is on the year 2018. Give an alias name to the average fine amount as 'average_fine_amount'.Note:1. Display only the average fine_amount with the given payment_date from bill table.2. Specify the alias name without any mistake.3.Specify the condition and retrieve the correct rows in the result(condition need to be specified on fine amount).4. Compare your executed result with the sample output given below.Sample output:
Solution
Here is the SQL query you need to write to get the desired output:
SELECT AVG(fine_amount) AS average_fine_amount
FROM bills
WHERE YEAR(payment_date) = 2018;
Let's break it down:
-
SELECT AVG(fine_amount) AS average_fine_amount: This part of the query is calculating the average of thefine_amountcolumn and giving it an alias nameaverage_fine_amount. -
FROM bills: This part of the query is specifying the table from which we want to select data, which is thebillstable. -
WHERE YEAR(payment_date) = 2018: This part of the query is the condition that filters the data. It only includes the rows where the year of thepayment_dateis 2018.
This query will return the average fine amount for the bills paid in the year 2018.
Similar Questions
Write a query to display the average payable_amount from bill table where payable_amount is greater than 10000. Give an alias name to the average payable amount as 'average_payable_amount'.Note:1. Display only the average payable_amount with the given payable_amount from bill table.2. Specify the alias name without any mistake.3. Specify the condition and retrieve the correct rows in the result(condition need to be specified on payable_amount).3. Compare your executed result with the sample output given below.Sample outp
Write a query to display the sum of payable_amount whose payment_date is on the year 2018. Give an alias name to the total payable_amount as 'sum_payable_amount'.Note:1. Display only the sum of payable_amount in the given year from bill table.(only for the year 2018).2. Specify the alias name without any mistake.3.Specify the condition and retrieve the correct rows in the result(condition need to be specified on payment_date column).4. Compare your executed result with the sample output given below.
Write a query to display the standard deviation of the fine_amount whose payment_date is on the year 2018 from bill table. Give an alias name to the standard deviation to the fine amount as 'standard_deviation_amount'.
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 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'.Note:1. Display only the sum of payable_amount and fine_amount from bill table.2. Specify the alias name without any mistake.3. Compare your executed result with the sample output given below.Sample output:
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.