Week3 - Retrieve Data using the SQL SELECT Statements / Design | E-BOX DBMS

Week3 - Retrieve Data using the SQL SELECT Statements / Design | E-BOX DBMS

Week3 - Retrieve Data using the SQL SELECT Statements / Design

The questions can come in any order, so make sure you are selecting right option for all questions.

1. Write a query to display the entire contents of the 'electricity_connection_type'. Display the records in ascending order based on their connection name.

    select * from electricity_connection_type order by connection_name  asc;

2. Write a query to display all the details of the 'building_type' .Display the records in ascending order based on names.

    select * from building_type order by name asc;

3. Write a query to display the entire contents of the 'building'.Display the records in ascending order based on owner name.

    select * from building order by owner_name;

4. Write a query to display the entire contents of the 'electricity_reading', Display the records in descending order based on 'total_units'.

    select * from electricity_reading order by total_units desc;

5. Write a query to display all 'meter_number' from meter table.

    select meter_number from meter;

6. Write a query to display the owner_name and contact_number of all building, Display the records in ascending order based on owner_name.

    select owner_name,contact_number from building order by owner_name;

7. Write a query to display the total_units, payable_amount and fine_amount of bill table. Display the records in descending order based on their total_units.

    select total_units,payable_amount,fine_amount from bill order by total_units desc;

8. Write a query to display the entire contents of the 'slab' details.Display the records in ascending order based on their 'from_unit'.

    select * from slab order by from_unit;

9. 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.

    select distinct h12 from electricity_reading order by h12 desc;

10. Write a query to display the entire contents of bill table. Display the records sorted in ascending order based on month and then in descending order based on total_units.

    select * from bill order by month asc, total_units desc;