Re: a lil sql help please.
At 18:51 9.7.2006, you wrote: Hi, I have the following Query and Im a lil lost on this one SELECT DISTINCT tbe_orders.order_id, tbe_orders.order_date, tbe_orders.order_piececount FROM tbe_orders SELECT tbe_orders.order_id, tbe_orders.order_date, sum(tbe_orders.order_piececount) FROM tbe_orders GROUP BY tbe_orders.order_id or SELECT tbe_orders.order_id, tbe_orders.order_date, sum(tbe_orders.order_piececount) FROM tbe_orders GROUP BY tbe_orders.order_id, tbe_orders.order_date depending whether date matters or not. Regards, Dundo. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: a lil sql help please.
m i l e s wrote: Hi, I have the following Query and Im a lil lost on this one SELECT DISTINCT tbe_orders.order_id, tbe_orders.order_date, tbe_orders.order_piececount FROM tbe_orders The query produces the following results: +++ + order_id + order_date + order_piececount + +++ + oid1 + 2006-07-08 +1 + + oid1 + 2006-07-08 +2 + + oid1 + 2006-07-08 +3 + + oid5 + 2006-07-08 +7 + + oid5 + 2006-07-08 +1 + + oid4 + 2006-07-08 +1 + + oid4 + 2006-07-08 +2 + + oid4 + 2006-07-08 +1 + +++ This is actually right. However, ideally what I'm wanting is this: +++ + order_id + order_date + order_piececount + +++ + oid1 + 2006-07-08 +6 + + oid5 + 2006-07-08 +8 + + oid4 + 2006-07-08 +4 + +++ Note the order_piececount column. What do I need to do to my SQL statement to perform this action ? My guess that I need to perform a secondary query inside the statement to get the computed value of order_piececount. Anyone ? M i l e s. SELECT DISTINCT tbe_orders.order_id, tbe_orders.order_date, SUM(tbe_orders.order_piececount ) FROM tbe_orders GROUP BY order_id; -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]