Knowee
Questions
Features
Study Tools

Write a query to display the rate from the slab table whose meter_number is 'SG567423'. If there are multiple records display in ascending order based on rate.Note:1. Display only the rate from the slab whose meter number is 'SG567423' from electricity_connection_type table.2. Tables involved are slab, electricity_connection_type, building_type, building and meter3. Order by is mandatory4. Compare your executed result with the sample output given below.

Question

Write a query to display the rate from the slab table whose meter_number is 'SG567423'. If there are multiple records display in ascending order based on rate.Note:1. Display only the rate from the slab whose meter number is 'SG567423' from electricity_connection_type table.2. Tables involved are slab, electricity_connection_type, building_type, building and meter3. Order by is mandatory4. Compare your executed result with the sample output given below.

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

Solution

Based on your instructions, here is a SQL query that should give you the desired output:

SELECT slab.rate
FROM slab
JOIN electricity_connection_type ON slab.connection_type_id = electricity_connection_type.id
JOIN building_type ON electricity_connection_type.building_type_id = building_type.id
JOIN building ON building_type.id = building.building_type_id
JOIN meter ON building.id = meter.building_id
WHERE meter.meter_number = 'SG567423'
ORDER BY slab.rate ASC;

This query works as follows:

  1. It selects the 'rate' column from the 'slab' table.
  2. It joins the 'slab' table with the 'electricity_connection_type' table where the 'connection_type_id' in the 'slab' table matches the 'id' in the 'electricity_connection_type' table.
  3. It then joins the 'electricity_connection_type' table with the 'building_type' table where the 'building_type_id' in the 'electricity_connection_type' table matches the 'id' in the 'building_type' table.
  4. It then joins the 'building_type' table with the 'building' table where the 'id' in the 'building_type' table matches the 'building_type_id' in the 'building' table.
  5. It then joins the 'building' table with the 'meter' table where the 'id' in the 'building' table matches the 'building_id' in the 'meter' table.
  6. It filters the results where the 'meter_number' in the 'meter' table is 'SG567423'.
  7. Finally, it orders the results in ascending order based on the 'rate' in the 'slab' table.

This problem has been solved

Similar Questions

Write a query to display the connection name ,from_unit and to_unit and rate of all the slabs.Display the records in ascending order based on connection_name.Note:1. Display connection name ,from_unit, to_unit and rate from slab and electricity_connection_type table.2. Use Joins3. Tables involved slab and electricity_connection_type.4. 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 of the building_type named 'College'. Display the records in ascending order based on their meter_number.Note:1. Display only the meter_number column present in the meter table where building_type name is ‘College’. Use subqueries to achieve this.2. Tables involved are building_type, building and meter.3. Order by is mandatory4. Compare your executed result with the sample output given below.

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 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.Note:1. Display only the columns meter_id and total_units present in the electricity_reading table.2. Specify the condition and retrieve the correct rows in the result. (condition need to be specified on h13 and h14 column)3. You can compare your executed result with the sample output given below.4. Order by is mandatorySample output: [Only few records are shown here]

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

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.