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.
Question
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.
Solution
Sure, here is the SQL query you asked for:
SELECT *
FROM building
WHERE owner_name LIKE 'M%'
ORDER BY owner_name ASC;
Here's a step-by-step explanation of the query:
-
SELECT * FROM building: This part of the query selects all columns from the 'building' table. -
WHERE owner_name LIKE 'M%': This is a condition that filters the records. It only selects the rows where the 'owner_name' starts with 'M'. The '%' is a wildcard character that matches any sequence of characters. -
ORDER BY owner_name ASC: This part of the query sorts the resulting records in ascending order ('ASC') based on the 'owner_name'. If you wanted to sort in descending order, you would use 'DESC' instead of 'ASC'.
Similar Questions
Write a query to display the owner_name and contact_number of all building, Display the records in ascending order based on owner_name.
Write a query to display all the details of the buildings whose owner name contains 'di' in ascending order based on the owner name of the building.Note:1. Display all the columns from the building table whose owner_name contains “di” from building table.2. Order by is mandatory3. Compare your executed result with the sample output given below.
Write a query to display the owner name and the length of the owner's name of the buildings. Display the records in ascending order based on owner name. Give an alias as name_length to the length of the owner names.Use the inbuilt function length().Note:1. Display only the owner name and length of the owner_name from building table.2. Specify the alias name without any mistake.3. Order by is mandatory4. Compare your executed result with the sample output given below.Sample output:[only few records shown here]
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
Write a query to display all the details of the buildings, whose building type name contains a letter 'e' but do not contain a letter 'a'. Display the records in descending order based on their owner_name.Note: Use 'Minus'Note:1. Display all the details of the buildings contains a letter 'e' but do not contain a letter 'a'.2. Order by is mandatory. 3. Use Minus.4. Compare your executed result with the sample output given below.Submit
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.