Knowee
Questions
Features
Study Tools

QueryQ2Write a query to display the meter number,owner name,address and contact number of all the buldings. Display the record in ascending order based on owner name.Note:1. Display only the below 4 columns,     i. meter number     ii. owner name     iii. address     iv. contact number 2. Use Joins3. Tables involved building and meter4. Order by is mandatory.5. Compare your executed result with the sample output given below.Sample output: [Only few records are shown here]

Question

QueryQ2Write a query to display the meter number,owner name,address and contact number of all the buldings. Display the record in ascending order based on owner name.Note:1. Display only the below 4 columns,     i. meter number     ii. owner name     iii. address     iv. contact number 2. Use Joins3. Tables involved building and meter4. Order by is mandatory.5. Compare your executed result with the sample output given below.Sample output: [Only few records are shown here]

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

Solution

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

SELECT 
    meter.meter_number, 
    building.owner_name, 
    building.address, 
    building.contact_number
FROM 
    building
JOIN 
    meter ON building.building_id = meter.building_id
ORDER BY 
    building.owner_name ASC;

This query works as follows:

  1. SELECT meter.meter_number, building.owner_name, building.address, building.contact_number: This line is selecting the four columns that you want to display.

  2. FROM building: This line is specifying the main table that we are selecting from, which is the building table.

  3. JOIN meter ON building.building_id = meter.building_id: This line is joining the meter table with the building table. The ON keyword is used to specify the column upon which the tables should be joined. In this case, it's the building_id column.

  4. ORDER BY building.owner_name ASC: This line is ordering the output in ascending order by the owner_name column in the building table. The ASC keyword specifies that the sorting should be in ascending order. If you wanted to sort in descending order, you would use the DESC keyword.

This problem has been solved

Similar Questions

Write a query to display the  meter number,owner name,address,contact number,building type name and connection name of all buildings.Display the records in ascending order based on building type name.Note:1. Display only the below 6 columns,     i. meter number     ii. owner name     iii. address     iv. contact number     v. building type name     vi. Connection name  2. Use Joins3. Tables involved building, meter, building_type, electricity_connection_type4. Order by is mandatory.5. Compare your executed result with the sample output given below.Sample output: [Only few records are shown here]

Write a query to display the owner_name and contact_number of all building, Display the records in ascending order based on owner_name.Note:1. Display only the column named ‘owner_name’ and ‘contact_number’ present in the building table.2. Order by is mandatory

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 building owner name ,address and number of connections present in each building. Display the records in ascending order based on owner name.Give an alias name as connection_count.Note:1. Display only the building owner_name ,address and number of connections.2. Use Joins3. Tables involved building, building_type, meter4. Specify the alias name without any mistake.5. Order by is mandatory. 6. Compare your executed result with the sample output given below.

Write a query to get the owner_name from the building table who have consumed maximum total_units of current in a month. Display the records in ascending order based on their owner_name.Note:1. Display only the owner_name from the building table who have consumed maximum total_units of current in a month.2. Tables involved are building, 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.