mysql - Sort and Group by Time -
i have following table:
line date time order qty 3 1140531 24737 s215037 1 3 1140531 24737 s215037 1 2 1140531 14955 s215058 1 2 1140531 14955 s215058 1 2 1140531 24055 s215059 1 2 1140531 24055 s215060 1 3 1140530 25319 s215099 1 3 1140530 25319 s215099 1
i need able display line, work order, sum of qty (i need show order completed first on desc based on date , time). end result should this:
line order sum of qty 2 s215058 2 2 s215059 1 2 s215060 1 3 s215099 2 3 s215037 2
attempt:
i have query updates data table it's ordered line, date, time apply following query:
select line, order, sum(qty) mytable group line, order
when group items, groups orders based on alphabetical order , not time. please help!
i feel contradiction between description , expected result mention word desc
. anyway following query give end result.
select `line`, `order`, sum(qty) mytable group `line`, `order` order `line`, `date`, `time`, `order`;
sql fiddle here: http://www.sqlfiddle.com/#!2/456bf/8
Comments
Post a Comment