Mysql order by clause

296 views
215 views

Published on

Aggregate functions, Order by clause, Having Clause, Distinct Clause

Published in: Education, Spiritual, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
296
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mysql order by clause

  1. 1. Aggregate Functions Order by clause Having Clause Distinct Clause
  2. 2. Count Max Min Avg Sum
  3. 3. The default sort order is ascending, with smallest values first. To sort in reverse (descending) order, add the DESC keyword to the name of the column you are sorting by:
  4. 4. SELECT ordernumber , itemsCount , sum(priceeach) AS total FROM orderdetails GROUP BY ordernumber
  5. 5. order to remove the duplicate rows, we use the DISTINCT operator in the SELECT statement. General Syntax SELECT DISTINCT columns FROM table_name WHERE where_conditions
  6. 6. SELECT lastname FROM employees ORDER BY lastname
  7. 7. SELECT DISTINCT lastname FROM employees ORDER BY lastname

×