Thursday, 15 January 2015

mysql - Sum Qty by date on date-time field -



mysql - Sum Qty by date on date-time field -

i'm trying sum qty built (partnum), grouped date, lot & partnum.

date partnum lot qty e.g. 2/15/13 1003 56 21 2/15/13 1007 23 12 select `product_trans`.`ptid` `id`, `product_trans`.`ptlot` `lot`, `product_trans`.`ptrole` `role`, `product_trans`.`ptposted` `posted`, `product_trans`.`ptstamp` `stamped`, `product_trans`.`ptline` `line`, sum(`product_trans`.`ptqty`) `qty`, `product_trans`.`ptpart` `part`, `product_trans`.`ptpartnum` `partnum` `product_trans` grouping `product_trans`.`ptstamp`, `product_trans`.`ptpartnum`, `product_trans`.`ptlot` order `product_trans`.`ptstamp`, `product_trans`.`ptpartnum`

the problem ptstamp date-time field. need grouped date, not date-time.

i tried this:

group curdate(`product_trans`.`ptstamp`), `product_trans`.`ptpartnum`, `product_trans`.`ptlot`

but no joy.

i know simple, can't see it.

try

date(`product_trans`.`ptstamp`)

mysql date function

mysql

No comments:

Post a Comment