Knowee
Questions
Features
Study Tools

Write a query to display all the building details in which building_type named ‘Library’. Display the records in ascending order based on their owner_name.Note:1. Display all the column present in the building table where building_type name is ‘Library’. Use subqueries to achieve this.2. Tables involved are building_type and building3. Order by is mandatory.

Question

Write a query to display all the building details in which building_type named ‘Library’. Display the records in ascending order based on their owner_name.Note:1. Display all the column present in the building table where building_type name is ‘Library’. Use subqueries to achieve this.2. Tables involved are building_type and building3. Order by is mandatory.

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

Solution

Here is the SQL query you asked for:

SELECT *
FROM building
WHERE building_type IN (
    SELECT id
    FROM building_type
    WHERE name = 'Library'
)
ORDER BY owner_name ASC;

This query works as follows:

  1. The subquery (SELECT id FROM building_type WHERE name = 'Library') selects the ID of the building type named 'Library'.
  2. The main query selects all columns from the building table where the building_type is in the list of IDs returned by the subquery.
  3. The ORDER BY owner_name ASC clause sorts the result in ascending order by the owner_name column.

This problem has been solved

Similar Questions

Display all the column present in the building table where building_type name is ‘Library’. Use subqueries to achieve this.2. Tables involved are building_type and building3. Order by is mandatory.4. Compare your executed result with the sample output given below.

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 entire details of the building whose building_type_id is 2, sorted by owner_name in ascending order.Note:1. Display all the columns present in the building table.2. Specify the condition and retrieve the correct rows in the result(condition need to be specified on building_type_id column).3. You can compare your executed result with the sample output given below.4. Order by is mandatorySample output:

Write a query to display the name of all building types that ends with letter 'l'. Display the records in ascending order based on name.Note:1. Display only the name of building types that ends with L from building_type table.2. Order by is mandatory3. Compare your executed result with the sample output given below.

Write a query to display the entire details of the 'building' whose owner_name starts with the letter 'M', Display the records in ascending order based on their owner_name.Note:1. Display all the columns present in the building table.2. Specify the condition and retrieve the correct rows in the result(condition need to be specified on owner_name 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]

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.