Knowee
Questions
Features
Study Tools

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.

Question

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.

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

Solution

Here is a SQL query that should give you the desired result:

SELECT m.meter_number
FROM meter m
JOIN bill b ON m.meter_id = b.meter_id
WHERE b.fine_amount = (
    SELECT MAX(fine_amount)
    FROM bill
    WHERE MONTH(bill_date) = MONTH(CURRENT_DATE)
    AND YEAR(bill_date) = YEAR(CURRENT_DATE)
)

This query works as follows:

  1. It joins the meter and bill tables on the meter_id field.
  2. It then filters the records for the current month and year.
  3. It selects the meter_number where the fine_amount is equal to the maximum fine_amount for the current month and year.

Please replace CURRENT_DATE with the specific month you are interested in if you are not looking for the current month.

This problem has been solved

Similar Questions

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 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.Sample output:

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

Write a query to display the month and sum of fine_amount collected on the month between July to October. Give an alias name as 'monthly_fine_amount' also display the records in ascending order based on month.Note:1. Display only the month and sum of fine_amount collected in the month between July to October from bill table. (month will be 01, 02, 03,...12)2. Specify the alias name without any mistake.3. Order by is mandatory4. Group by month to get the month wise sum of fine_amount5. Compare your executed result with the sample output given below.

Write a query to display the month and the minimum total_units of electricity consumed on that month from the bill table. Give an alias name to the minimum total_units as 'minimum_units'.Note:1. Display only the month and minimum total_units of electricity consumed from bill table.2. Specify the alias name without any mistake.3. Group by month to get minimum total_units of every month.4. Compare your executed result with the sample output given below.

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.