MySQL query - average amount of lines per order, on a monthly basis -


I have a table that shows the previous order.
Each item purchased is added as a separate line in the table, see Dump below.

My goal is to show the average amount per order on a monthly basis, to get an average amount of lines, I need to divide the amount of items bought by the amount of given orders.

My query presently gives me monthly sum, and line_count return is the correct number of items purchased, but I think the amount of given orders can not be recovered ( Dump should be given at 13 below) I have tried to add different subqueries, but I'm not sure how to go about this any idea?

  Select Date, COUNT (orderno) between `orders` and date '2010-01-21' by line_count and CURDATE () group as month (date), year (on) Sort by date   

table schema (simplified for clarity) here

  table form are not `Well Orders` (` Id` integer (11) not NULL AUTO_INCREMENT, `orderno` varchar (15) NULL not utf8_unicode_ci juxtaposition,` date` not on NULL, pRIMARY KEY ( `Id`)) eNGINE = MyISAM default charset = UTF8 reactance = utf8_unicode_ci AUTO_INCREMENT = 22,904; - - Enter the data dumping for table `command` (` id`, `orderno`,` date`) in the value (1, 'rad10000', '2010-01-21'), (2, ' Red 10000 ',' 2010-01-21 '), (3,' red 10001 ',' 2010-01-21 '), (4,' red 10001 ',' 2010-01-21 '), (5, Rdl0002 ',' 2010-01-21 '), (6' Rdl0003 ',' 2010-01-21 '), (8' Rdl0003 ',' 2010-01-21 '), (9,' Rdl0003 ' , '2010-01-21'), (10, 'rad10004', '2010-01-22'), (11, 'rad10004', '2010-01-22'), (12, 'rad10005', ' 2010-01-22 '), (13,' red 1, 0005 ',' 2010-01-22 '), (14,' red1, 0006 ',' 2010-01-22 '), (15, Red-10007 ',' 2010-01-22 '), (16,' red-10008 ',' 2010-01-22 '), (17,' red 1, 000 9 ',' 2010-01-22 ' ), (18, 'red 10010', '2010-01-22'), (19, 'red 10011', '2010-01-22'), (20, 'red 10012', '2010-01-22 ');    

Oh, I see ...

 < Code> (year) was ordered from the year (date), month (date), COUNT (*) linemount, COUNT (separate order) orders, where date '2010-01-21' and by the Kurt Group Date by date (date), month (date) order;    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -