Skip to content

Commit 10224e8

Browse files
committed
Important One.
1 parent 0f12ba9 commit 10224e8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

4. Sorting.sql

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- 1. sort by ascending
2+
select name from student order by id;
3+
4+
--2 sort by descending
5+
select name from student order DESC by id;
6+
7+
-- sort the string from starting index to n letters.
8+
select name from student order by Left(name,3);
9+
10+
11+
-- sort the string from last index to n letters.
12+
select name from student order by Right(name,3);
13+
14+
-- if above 2 matches then under such condition
15+
-- we got to use 'ID' attributes for sort.
16+
17+
select name from student order by Left/Right(name,n),ID;
18+

0 commit comments

Comments
 (0)