distinct and order by in SQL

distinct and order by in SQL

distinct and order by in SQL

1: Open the MySQL Workbench.

2: Check the names in the Ascending style.

Code: SELECT * FROM student ORDER by name ASC

3: Execute the command.

Shortcut key: Ctrl + Enter

distinct and order by in SQL 1

4: Check the names in the Descending style.

Code: SELECT * FROM student ORDER by name DESC

5: Execute the command.

Shortcut key: Ctrl + Enter

distinct and order by in SQL 2

6: Same procedure for age.

Ascending style Code: SELECT * FROM student ORDER by age ASC

Descending style Code: SELECT * FROM student ORDER by age DESC

7: Execute the command.

Shortcut key: Ctrl + Enter

distinct and order by in SQL 3

8: Check the unique city names.

Code: SELECT DISTINCT city FROM student

9: Execute the command.

Shortcut key: Ctrl + Enter

distinct and order by in SQL 4

10: Check the Unique age.

Code: SELECT DISTINCT age FROM student

11: Execute the command.

Shortcut key: Ctrl + Enter

distinct and order by in SQL 5

12: Check the age by the Ascending style.

Code: SELECT DISTINCT age FROM student ORDER by age ASC

13: Execute the command.

Shortcut key: Ctrl + Enter

distinct and order by in SQL 6

MySQL

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top