Knowee
Questions
Features
Study Tools

Write 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

Question

Write 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

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

Solution

The SQL query to display all the 'bills' with 'meter' details in ascending order based on meter number would look like this:

SELECT *
FROM bill
JOIN meter
ON bill.METER_ID = meter.ID
ORDER BY meter.METER_NUMBER ASC;

Here's a step-by-step breakdown of the query:

  1. SELECT * - This selects all columns from the tables we're going to mention next.

  2. FROM bill - This specifies the first table we're pulling data from, which is the 'bill' table.

  3. JOIN meter - This is the SQL JOIN clause, which combines rows from two or more tables based on a related column between them. In this case, we're joining the 'bill' table with the 'meter' table.

  4. ON bill.METER_ID = meter.ID - This is the condition that must be met for the rows to be combined. We're saying that the 'METER_ID' column in the 'bill' table must be equal to the 'ID' column in the 'meter' table.

  5. ORDER BY meter.METER_NUMBER ASC; - This sorts the resulting records in ascending order ('ASC') based on the 'METER_NUMBER' column in the 'meter' table. If you wanted to sort the records in descending order, you would use 'DESC' instead of 'ASC'.

Please note that this is a basic JOIN query and assumes that 'METER_ID' in the 'bill' table and 'ID' in the 'meter' table are related, and that 'METER_NUMBER' in the 'meter' table is a numeric field. If your database schema is different, you may need to adjust the query accordingly.

This problem has been solved

Similar Questions

Write a query to display the meter_number,owner_name and address of the owner who paid second least  fine total amount. If there are multiple records display in ascending order based on owner name.Note:1. Display only the below 3 columns,     i. meter number     ii. owner name     iii. address  with the condition who paid seocnd least fine total amount.2. Use Joins3. Tables involved are building, meter and bill4. Order by is mandatory.5. Compare your executed result with the sample output given below.Sample output:

Write a query to display the meter_number from the meter table which got minimum amount of total_units in a month. Display the records in ascending order based on their meter_number.Note:1. Display only the meter_number from the meter table which got minimum amount of total_units in a month.2. Tables involved are meter and bill3. Order by is mandatory4. Compare your executed result with the sample output given below

Write a query to display owner name,address ,meter number and payable amount of all the bill which are all not having fine_amount and that are generated for 2017 December. Display the records in ascending order based on owner name.Note:1. Display only the below 4 columns,     i. owner name     ii. address     iii. meter number     iv. payable_amountwith the condition not having fine_amount that are generated for 2017 December.2. Use Joins3. Tables involved building, meter and bill4. Specify condition on year, month and fine_amount columns of bill table. year must be 2017, month must be 12 and fine_amount should be not null5. Order by is mandatory. 6. Compare your executed result with the sample output given below.

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:

Write a query to display owner name,address ,meter number and total units consumed by all the customers in the month december 2017.Display the records in descending order by total_units.Note:1. Display only the below 4 columns,     i. owner name     ii. address     iii. meter number     iv. Total unitsby all the customers in the month december 2017.2. Use Joins3. Tables involved building, meter and bill4. Specify condition on year, month column of bill table5. Order by is mandatory.

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.