a. SORT BY
b. ORDER
c. ORDER BY
d. SORT
Which SQL Keyword Is Used To Sort The Result-Set
Answer. Option B) Order By is the Correct Answer
In SQL, the ORDER BY
the keyword is used to sort the result set of a query. You can use it to specify one or more columns by which you want to sort the rows in the result set, and you can also specify the sort order, which can be ascending (ASC) or descending (DESC).
Here’s the basic syntax of the ORDER BY
clause:
SELECT column1, column2, ...
FROM table_name
ORDER BY column1 [ASC | DESC], column2 [ASC | DESC], ...;
column1, column2, ...
specifies the columns you want to retrieve in the result set.table_name
is the name of the table from which you’re selecting data.ORDER BY
is followed by one or more column names by which you want to sort the result set. You can also specify the sort order asASC
(ascending) orDESC
(descending).
For example, if you want to retrieve records from a “employees” table and sort them by the “last_name” column in ascending order, you would use the following SQL query:
SELECT *
FROM employees
ORDER BY last_name ASC;
This would return the rows sorted by the “last_name” column in alphabetical order.
Hello, I’m Hridhya Manoj. I’m passionate about technology and its ever-evolving landscape. With a deep love for writing and a curious mind, I enjoy translating complex concepts into understandable, engaging content. Let’s explore the world of tech together