Hope you don't mind. It's not a MySQL problem, but it is an SQL problem that I'm having difficulty with.
The above query works and shows the products that have been returned.Code:SELECT LEFT(ITEM, 10) AS Expr1, SUM(QUANTS) AS Returns FROM ITEMS WHERE ITEM_STATE = 'RT' GROUP BY LEFT(ITEM, 10) ORDER BY Returns DESC
However to make any sense of this query I'd also like to add two additional columns to this above query.
The extra columns would be
1. Items shipped
2. A percentage showing Items Returned/Items Shipped.
Therefore we can see if we are having return problems with particular items, where the % of returns are high.
The problem is that items shipped uses the same columns as items returned so I'm not sure how to combine this on the same query.
As an example if I wanted just to see items shipped i would use the following query.
Any help is much appreciated!Code:SELECT LEFT(ITEM, 10) AS Expr1, SUM(QUANTS) AS Shipped FROM ITEMS WHERE ITEM_STATE = 'SH' GROUP BY LEFT(ITEM, 10) ORDER BY Shipped DESC