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'.Note:1. Display only the sum of payable_amount with the given due_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 due_date).4. Compare your executed result with the sample output given below.Sample output:
Question
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'.Note:1. Display only the sum of payable_amount with the given due_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 due_date).4. Compare your executed result with the sample output given below.Sample output:
Solution 1
Here is the SQL query you need to write to get the desired output:
SELECT SUM(payable_amount) AS sum_payable_amount
FROM bill
WHERE due_date = '2017-10-01';
Let's break down this query:
-
SELECT SUM(payable_amount) AS sum_payable_amount: This part of the query is used to calculate the sum of thepayable_amountcolumn. TheASkeyword is used to give this sum a name, or alias, which issum_payable_amount. -
FROM bill: This part of the query specifies the table we are selecting data from, which is thebilltable. -
WHERE due_date = '2017-10-01': This is the condition that the rows must meet in order to be included in the sum. Only the rows wheredue_dateis '2017-10-01' will be included.
After executing this query, you will get the total payable amount for the bills due on '2017-10-01'.
Solution 2
The SQL query to achieve this would be:
SELECT SUM(payable_amount) AS sum_payable_amount
FROM bill
WHERE due_date = '2017-10-01';
Here's how this query works:
-
SELECT SUM(payable_amount) AS sum_payable_amount: This part of the query is used to calculate the sum of thepayable_amountcolumn. TheASkeyword is used to give this sum a name, or alias, which issum_payable_amount. -
FROM bill: This part of the query specifies the table we are selecting data from, which is thebilltable. -
WHERE due_date = '2017-10-01': This is the condition that the rows must meet in order to be included in the sum. Only rows where thedue_dateis '2017-10-01' will be included.
After executing this query, you will get the total payable amount for the bills due on '2017-10-01'.
Solution 3
The SQL query to achieve this would be:
SELECT SUM(payable_amount) AS sum_payable_amount
FROM bill
WHERE due_date = '2017-10-01';
Here's the step by step explanation:
-
SELECT SUM(payable_amount) AS sum_payable_amount: This part of the query is used to calculate the sum of thepayable_amountcolumn from thebilltable. TheASkeyword is used to give this sum an alias name,sum_payable_amount. -
FROM bill: This part of the query specifies the table from which we want to retrieve data, which is thebilltable in this case. -
WHERE due_date = '2017-10-01': This is the condition that filters the data. It only includes the rows where thedue_dateis '2017-10-01'.
When you run this query, it will return the sum of the payable_amount for all bills that have a due_date of '2017-10-01'. This sum will be displayed under a column named sum_payable_amount.
Solution 4
The SQL query to achieve this would be:
SELECT SUM(payable_amount) AS sum_payable_amount
FROM bill
WHERE due_date = '2017-10-01';
Here's the step by step explanation:
-
SELECT SUM(payable_amount) AS sum_payable_amount: This part of the query is used to calculate the sum of thepayable_amountcolumn from thebilltable. TheASkeyword is used to give an alias name to the sum of payable amount, which issum_payable_amount. -
FROM bill: This part of the query specifies the table from which we want to retrieve the data, which is thebilltable. -
WHERE due_date = '2017-10-01': This is the condition that needs to be met for the rows to be included in the result. It specifies that we only want to include rows where thedue_dateis '2017-10-01'.
When you run this query, it will return the sum of the payable_amount for all bills with a due_date of '2017-10-01', and this sum will be displayed under the column name sum_payable_amount.
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'.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:
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 details of all the 'bill' with the due_date on '2017-10-01'.Display the records in descending order based on their payable_amount.
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:
Write a query to display the sum of payable_amount of all the bills from bill table.Give an alias name to the sum of payable amount as 'sum_payable_amount'.Note:1. Display the sum of payable_amount from bill.2. Specify the alias name without any mistake.3. Compare your executed result with the sample output given below.Sample output: SubmitSaveExecutePrevious Submission
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.