English
Tamil Nadu Board of Secondary EducationHSC Science Class 12

Construct the following SQL statement in the student table- SELECT statement using ORDER BY clause. - Computer Science

Advertisements
Advertisements

Question

Construct the following SQL statement in the student table-

SELECT statement using ORDER BY clause.

Answer in Brief
Advertisements

Solution

ORDER BY clause

The ORDER BY clause in SQL is used to sort the data in either ascending or descending based on one or more columns.
1. By default ORDER BY sorts the data in ascending order.
2. We can use the keyword DESC to sort the data in descending order and the keyword ASC to sort in ascending order.

The ORDER BY clause is used as:

SELECT <column-name> [,<column-name>,….] FROM <table-name> ORDER
BY <column1>,<column2>, …ASC\ DESC;

For example :

To display the students in alphabetical order of their names, the command is used as
SELECT * FROM Student ORDER BY Name;

The above student table is arranged as follows :

Admno Name Gender Age Place
104 Abinandh M 18 Chennai
101 Adarsh M 18 Delhi
102 Akshith M 17 Bangalore
100 Ashish M 17 Chennai
103 Ayush M 18 Delhi
106 Devika F 19 Bangalore
107 Hema F 17 Chennai
105 Revathi F 19 Chennai
  
shaalaa.com
SQL Commands and Their Functions
  Is there an error in this question or solution?
Chapter 12: Structured Query Language (SQL) - Evaluation [Page 231]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 12 TN Board
Chapter 12 Structured Query Language (SQL)
Evaluation | Q 4. (ii) | Page 231
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×