Use of order by statement.

Use of ORDER BY Statement Use of order by statement
The ORDER BY keyword is used to sort the result-set in ascending or descending order. The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.
Syntax*
SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;
QUERY*
CREATE TABLE stud_113
(Rollno NUMBER(5), name VARCHAR(10), address VARCHAR(15),
phoneno NUMBER(10), age NUMBER(5));
As Shown in Fig...7.1
Output
Fig... 7.1
QUERY*
INSERT INTO stud_113 VALUES(3);
INSERT INTO stud_113 VALUES(2);
INSERT INTO stud_113 VALUES(5);
INSERT INTO stud_113 VALUES(4);
INSERT INTO stud_113 VALUES(1);
INSERT INTO stud_113 VALUES(6);
As Shown in Fig...7.2
Output
Fig... 7.2
QUERY*
SELECT * FROM stud_113 ORDER BY rollno DESC;
As Shown in Fig...7.3
Output
Fig... 7.3

Comments

Popular posts from this blog

SQL IS NOT NULL.

Database Management System

SQL BETWEEN Operator Example.