mysql order by clause

23
Aggregate Functions Order by clause Having Clause Distinct Clause

Upload: mustufa-nullwala

Post on 07-Jul-2015

133 views

Category:

Education


4 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Mysql order by clause

Aggregate FunctionsOrder by clauseHaving ClauseDistinct Clause

Page 2: Mysql order by clause

Count

Max

Min

Avg

Sum

Page 3: Mysql order by clause
Page 4: Mysql order by clause
Page 5: Mysql order by clause
Page 6: Mysql order by clause
Page 7: Mysql order by clause
Page 8: Mysql order by clause
Page 9: Mysql order by clause
Page 10: Mysql order by clause
Page 11: Mysql order by clause
Page 12: Mysql order by clause
Page 13: Mysql order by clause

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:

Page 14: Mysql order by clause
Page 15: Mysql order by clause
Page 16: Mysql order by clause
Page 17: Mysql order by clause

SELECT ordernumber , itemsCount ,

sum(priceeach) AS total FROM orderdetails

GROUP BY ordernumber

Page 18: Mysql order by clause
Page 19: Mysql order by clause
Page 20: Mysql order by clause

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

Page 21: Mysql order by clause

SELECT lastname FROM employees

ORDER BY lastname

Page 22: Mysql order by clause

SELECT DISTINCT lastname FROM employees

ORDER BY lastname

Page 23: Mysql order by clause