QueryQQ5Write a query to display the total_units and payable_amount of the particular meter number 'SG934826'.Note:1. Display only the total_units and payable_amount columns present in the bill table where meter_number is ‘SG934826’. Use subqueries to achieve this.2. Tables involved are bill and meter.3. Compare your executed result with the sample output given below.
Question
QueryQQ5Write a query to display the total_units and payable_amount of the particular meter number 'SG934826'.Note:1. Display only the total_units and payable_amount columns present in the bill table where meter_number is ‘SG934826’. Use subqueries to achieve this.2. Tables involved are bill and meter.3. Compare your executed result with the sample output given below.
Solution
To answer the question, you would need to write a SQL query. Here is a step-by-step guide on how to do it:
-
Identify the tables involved: From the question, we know that the tables involved are 'bill' and 'meter'.
-
Identify the columns to display: The question asks for 'total_units' and 'payable_amount' from the 'bill' table.
-
Identify the condition: The condition given is that the 'meter_number' should be 'SG934826'.
-
Write the query: Based on the above information, you can write the query as follows:
SELECT total_units, payable_amount
FROM bill
WHERE meter_number IN (SELECT meter_number FROM meter WHERE meter_number = 'SG934826');
This query will display the 'total_units' and 'payable_amount' for the meter number 'SG934826'. The subquery is used to select the 'meter_number' from the 'meter' table where 'meter_number' is 'SG934826'. The main query then selects 'total_units' and 'payable_amount' from the 'bill' table where 'meter_number' is in the list returned by the subquery.
Similar Questions
Write a query to display the total_units and payable_amount of the particular meter number 'SG934826
Write a query to display the meter_number from the meter table for which the bill is paid with maximum fine_amount of a month.Note:1. Display only the meter_number from the meter table for which the bill is paid with maximum fine_amount of a month.2. Tables involved are meter and bill3. Compare your executed result with the sample output given below.Sample output:
QueryQ1Write a query to display all the 'bills' with 'meter' details. Display the records in ascending order based on meter number.Note:1. Display all the columns of bill and meter table2. Use Joins3. Tables involved bill and meter4. Order by is mandatory5. Compare your executed result with the sample output given below.Sample output: [Only few records are shown here]ID METER_ID MONTH YEAR DUE_DATE TOTAL_UNITS PAYABLE_AMOUNT IS_PAYED PAYMENT_D FINE_AMOUNT ID METER_NUMBER BUILDING_ID39 26 8 2017 01-SEP-17 20700 724500 1 14-SEP-17 72450 26 SG190123 2614 10 10 2017 01-NOV-17 750 16875 1 09-NOV-17 1687.5 10 SG198329 10
Write a query to display all 'meter_number' from meter table
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.