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.
Question
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.
Solution
Assuming you are using SQL, here is a step-by-step guide on how to write the query:
-
First, you need to select the column you are interested in, which is the name of the building types. In SQL, you use the SELECT keyword to do this. If the column name is "building_type", the query starts like this:
SELECT building_type
-
Next, you want to specify which table to select this column from. Let's assume the table is called "buildings". You use the FROM keyword to specify the table. So far, the query looks like this:
SELECT building_type FROM buildings
-
Now, you want to filter the building types to only include those that end with the letter 'l'. You use the WHERE keyword to filter rows in SQL. To check if a string ends with a certain character, you can use the LIKE keyword with the '%' wildcard character. The '%' character in SQL is used to represent any sequence of characters. So, if you put it before 'l', it will match any string that ends with 'l'. The query now looks like this:
SELECT building_type FROM buildings WHERE building_type LIKE '%l'
-
Finally, you want to order the results in ascending order based on the building type name. You use the ORDER BY keyword to sort the results in SQL. By default, ORDER BY sorts the results in ascending order, so you don't need to explicitly specify it. Here is the final query:
SELECT building_type FROM buildings WHERE building_type LIKE '%l' ORDER BY building_type
This query will return the name of all building types that end with the letter 'l', sorted in ascending order.
Similar Questions
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 contact number of the building_type named 'Police Station'. Display the records in ascending order based on the contact number
Write a query to display all the details of the 'building' whose owner_name is 'Nicholas'.
Use a UNION to create a list of all the employee's and customer's first names and last names ordered by the last name in descending order.
Select all records from the Customers table, sort the result reversed alphabetically by the column City.
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.