Knowee
Questions
Features
Study Tools

Write a query to display the meter_id and total_units of electricity_reading whose '13th' hour reading is lesser than the '14th' hour reading, Display the records in descending order based on their total_units.

Question

Write a query to display the meter_id and total_units of electricity_reading whose '13th' hour reading is lesser than the '14th' hour reading, Display the records in descending order based on their total_units.

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

Solution 1

Assuming you are using SQL, here is a step-by-step guide on how to write the query:

  1. Identify the table: From the question, it seems like the table you are working with is electricity_reading.

  2. Identify the columns: The columns you are interested in are meter_id, total_units, 13th_hour_reading, and 14th_hour_reading.

  3. Write the SELECT statement: Start your query with SELECT meter_id, total_units FROM electricity_reading.

  4. Write the WHERE clause: You want to display records where the '13th' hour reading is lesser than the '14th' hour reading. So, add WHERE 13th_hour_reading < 14th_hour_reading.

  5. Write the ORDER BY clause: You want to display the records in descending order based on their total_units. So, add ORDER BY total_units DESC.

Putting it all together, your query should look like this:

SELECT meter_id, total_units 
FROM electricity_reading 
WHERE 13th_hour_reading < 14th_hour_reading 
ORDER BY total_units DESC;

Please replace 13th_hour_reading and 14th_hour_reading with the actual column names in your table.

This problem has been solved

Solution 2

Assuming you are using SQL and your table name is 'electricity_reading', the query would look something like this:

SELECT meter_id, total_units
FROM electricity_reading
WHERE hour_13 < hour_14
ORDER BY total_units DESC;

This query works as follows:

  1. SELECT meter_id, total_units: This line is selecting the columns 'meter_id' and 'total_units' to be displayed in the output.

  2. FROM electricity_reading: This line is specifying the table from which to select these columns.

  3. WHERE hour_13 < hour_14: This line is the condition for the rows to be selected. It's only selecting the rows where the reading of the 13th hour is less than the reading of the 14th hour.

  4. ORDER BY total_units DESC: This line is ordering the selected rows based on the 'total_units' column in descending order.

This problem has been solved

Similar Questions

Write a query to display the meter_number from the meter table which got minimum total_units during 9PM for a day in the electricity_reading. 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 total_units during 9PM. ( 9PM reading will be in h21 column).2. Tables involved are meter and electricity_reading3. Compare your executed result with the sample output given below.

Write a query to display unique 12th hour reading present in the electricity_reading table. Display the records sorted in descending order based on h12

Write a query to display all the details of the 'electricity_reading' whose 'total_units' per day is between 500 and 1000.Display the records in ascending order based on their total_units.

Write a query to display the electricity readings for the meters with meter number 'SG923564' and 'SG288942' in descending order based on the total units consumed per day.

Write a query to display the meter_number ,total_units, payable_amount and hourly usage of by morning, afternoon, evening and night for the month December 2017 of each meter. Display the record in descending order by total_units.Note:1. Display only the below 6 columns,     i. meter_number     ii. total_units     iii. payable_amount      iv. hourly usage by morning ( consider 6 to 11 as Morning )     v. hourly usage by afternoon ( consider 12 to 15 as afternoon )     vi. hourly usage by evening ( consider 16 to 19 as evening ) and     vii. Remaining as hourly usage by night.2. Use Joins3. Tables involved are electricity_reading, meter and bill4. Order by is mandatory.5. 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.