Search Knowledge Base Articles
group by date in where clause
SELECT SUM(OrderNetAmount) AS `orders`, DATE_FORMAT(Orders.OrderDate, '%d-%b-%y') as `OrderDate` FROM `Orders` WHERE `OrderSupplierID`=1 GROUP BY DAY(OrderDate)
SELECT SUM(OrderNetAmount) AS `orders`, DATE_FORMAT(Orders.OrderDate, '%d-%b-%y') as `OrderDate` FROM `Orders` WHERE `OrderSupplierID`=1 GROUP BY MONTH(OrderDate)
SELECT SUM(OrderNetAmount) AS `orders`, DATE_FORMAT(Orders.OrderDate, '%d-%b-%y') as `OrderDate` FROM `Orders` WHERE `OrderSupplierID`=1 GROUP BY YEAR(OrderDate) Did you find this article useful?
Related Articles
-
MySql Functions
DATE_SUB() Getting the recent one month or year records from MySQL table Syntax of DATE_SUB() DATE_SUB(date, INTERVAL, expression, UNIT) Example ...