GROUP BY Left(sku,5) hth, Arthur
-----Original Message----- From: Michael Stearne [mailto:mstearne@;entermix.com] Sent: Thursday, October 31, 2002 11:31 AM To: [EMAIL PROTECTED] Subject: Repeating Results in Query The query below: SELECT DISTINCT LEFT(sku,5) AS Item_Sku,count(*) as Quantity_Sold, SUM(price) AS Total_Sales FROM `orderline` WHERE (order_date>='20021030' AND order_date<='20021031') GROUP BY sku ORDER BY Item_Sku ASC Produces results like: Item_Sku Quantity_Sold Total_Sales LE104 1 18 MD008 1 25 MD012 1 5 MD103 1 18 MD104 10 400 MD104 3 120 MD201 1 18 MS012 2 6 MS022 1 5 MS106 1 18 MS107 1 18 The Sku field has values like: MD104-bk-HZ456-LG MD104-bk-HZ456-MD MD104-bk-HZ456-XL But I would like to group and find distinct matchings by just the first 5 characters of sku. But in the example MD104 repeats. Any idea why this is the case? Thanks, Michael --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php