Display only the contact_number column present in the building table where building_type name is ‘Police Station’. Use subqueries to achieve this.2. Tables involved are building_type and building.3. Order by is mandatory.4. Compare your executed result with the sample output given below.
Question
Display only the contact_number column present in the building table where building_type name is ‘Police Station’. Use subqueries to achieve this.2. Tables involved are building_type and building.3. Order by is mandatory.4. Compare your executed result with the sample output given below.
Solution
It seems like you're asking for a SQL query. Here's how you can do it:
SELECT contact_number
FROM building
WHERE building_type_id IN (
SELECT building_type_id
FROM building_type
WHERE building_type_name = 'Police Station'
)
ORDER BY contact_number;
Here's the step by step explanation:
-
The subquery
SELECT building_type_id FROM building_type WHERE building_type_name = 'Police Station'is used to find thebuilding_type_idof the 'Police Station' from thebuilding_typetable. -
This
building_type_idis then used in the main query to filter thebuildingtable and get thecontact_numberof buildings wherebuilding_type_idis the same as the one we got from the subquery. -
Finally, the
ORDER BY contact_numberis used to sort the result bycontact_number.
Please replace the table and column names with the actual ones in your database if they are different.
Similar Questions
Write a query to display all the contact number of the building_type named 'Police Station'. Display the records in ascending order based on the contact number.Note:1. Display only the contact_number column present in the building table where building_type name is ‘Police Station’. Use subqueries to achieve this.2. Tables involved are building_type and building.
Write a query to display all the contact number of the building_type named 'Police Station'. Display the records in ascending order based on the contact number.Note:1. Display only the contact_number column present in the building table where building_type name is ‘Police Station’. Use subqueries to achieve this.2. Tables involved are building_type and building.3. Order by is mandatory.4. Compare your executed result with the sample output given below.Sample output:SubmitSaveExecutePrevious Submission
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.
Display only the name column present in the building_type table where meter_number is ‘SG824012’. Use subqueries to achieve this.2. Tables involved are building_type, building and meter.3. 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.
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.