Knowee
Questions
Features
Study Tools

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

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

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

Solution 1

Sure, here is the SQL query you asked for:

SELECT AVG(fine_amount) AS average_fine_amount
FROM bills
WHERE YEAR(payment_date) = 2018;

This query works as follows:

  1. SELECT AVG(fine_amount) AS average_fine_amount: This part of the query is used to calculate the average of the fine_amount column. The AS keyword is used to give this average a new name, average_fine_amount.

  2. FROM bills: This part of the query specifies the table we are selecting data from, which is the bills table.

  3. WHERE YEAR(payment_date) = 2018: This is the condition for selecting the data. It selects the rows where the year of the payment_date is 2018. The YEAR() function extracts the year part from a date.

Please note that the actual function to extract the year from a date can vary depending on the SQL dialect you are using. The above query assumes you are using MySQL. If you are using a different SQL dialect, please let me know so I can adjust the query accordingly.

This problem has been solved

Solution 2

Sure, here is the SQL query you asked for:

SELECT AVG(fine_amount) AS average_fine_amount
FROM bills
WHERE YEAR(payment_date) = 2018;

Here is the step by step explanation:

  1. SELECT AVG(fine_amount) AS average_fine_amount: This part of the query is used to calculate the average of the fine_amount column. The AVG function calculates the average. The AS keyword is used to give an alias name to the result, which is average_fine_amount in this case.

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

  3. WHERE YEAR(payment_date) = 2018: This is the condition for selecting the rows. The YEAR function extracts the year part from the payment_date column. The condition is that the year must be 2018. So, this query will select the rows from the bills table where the year of payment_date is 2018, and then calculate the average of the fine_amount for those rows.

This problem has been solved

Solution 3

Sure, here is the SQL query you asked for:

SELECT AVG(fine_amount) AS average_fine_amount
FROM bills
WHERE YEAR(payment_date) = 2018;

This query works as follows:

  1. SELECT AVG(fine_amount) AS average_fine_amount: This part of the query is used to calculate the average of the fine_amount column. The AS keyword is used to give a name to the result, which in this case is average_fine_amount.

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

  3. WHERE YEAR(payment_date) = 2018: This is the condition that the rows must meet to be included in the average calculation. The YEAR function extracts the year part from the payment_date column, and we only include the rows where this is equal to 2018.

This problem has been solved

Similar Questions

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

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

Write a query to display the sum of payable_amount with due_date '2017-10-01' from bill table. Give an alias name to the sum of payable amount as 'sum_payable_amount'.

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.