Sorting Retrieved Data Flashcards

1
Q

ORDER BY

A

(basically ascending – A to Z)-

SELECT prod_name
FROM Products
ORDER BY prod_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ORDER BY 2 or more columns

A

SELECT prod_id, prod_price, prod_name
FROM Products
ORDER BY 2, 3;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

ORDER BY DESC (Z to A)

A

SELECT prod_name
FROM Products
ORDER BY prod_name DESC;

to apply DESC sorting to different column you must write DESC for every COLUMN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ORDER BY multiple columns

A

SELECT prod_id, prod_price, prod_name
FROM Products
ORDER BY prod_price DESC, prod_name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly