CBSE Class 12 Informatics Practices
Question 12 of 90
Querying Using SQL — Question 5
Back to all questionsFIELD()
Reason — The FIELD() function in SQL allows to specify a custom sort order by listing the values in the order we want them to appear.
For example, the following statement selects column fruit_name from the fruits table and orders the result set based on the custom sort order specified by the FIELD() function.
SELECT * FROM fruits
ORDER BY FIELD(fruit_name, 'Apple', 'Banana', 'Orange', 'Grapes');