I have a large order list that I need to create, and I need to get a list of product codes and their quantities on a per order basis.

To simplify, I'm showing an example for a single order, but the outer query will need to provide this result for every order in the system.

So far, I have the following:

```
mysql> select ProductCode,Quantity from OrderProducts where Order_ID = X;
+-------------+----------+
| ProductCode | Quantity |
+-------------+----------+
| PROD1       |        1 |
| PROD2       |        1 |
| PROD1       |        1 |
+-------------+----------+
3 rows in set (0.00 sec)

mysql> SELECT CONCAT(OrderProducts.ProductCode,' (',SUM(OrderProducts.Quantity),')') FROM OrderProducts WHERE Order_ID = X GROUP BY OrderProducts.ProductCode;
+------------------------------------------------------------------------+
| CONCAT(OrderProducts.ProductCode,' (',SUM(OrderProducts.Quantity),')') |
+------------------------------------------------------------------------+
| PROD1 (2)                                                              |
| PROD2 (1)                                                              |
+------------------------------------------------------------------------+
2 rows in set (0.00 sec)

```

What I need is a GROUP\_CONCAT result of the query above,but it won't let me wrap a GROUP\_CONCAT around the CONCAT shown above because I think because the SUM() is already doing grouping itself. Here is what I need to get back:

```
PROD1 (2),PROD2 (1)

```

**EDIT**

I was unclear about the use of the query above. I will be using that query as a subquery within a select which will be querying on ALL orders in `Orders`. Below is an updated version of the query:

```
SELECT 
  ( 
    SELECT 
      GROUP_CONCAT(SerialNumberedProductCount) 
    FROM  
    ( 
      SELECT 
        OrderProducts.Order_ID,
        CONCAT(OrderProducts.ProductCode,' (',SUM(OrderProducts.Quantity),')') AS SerialNumberedProductCount 
       FROM  
        OrderProducts, Products 
       WHERE 
        OrderProducts.Order_ID = Orders.Order_ID AND 
        OrderProducts.Product_ID = Products.Product_ID AND 
        Products.IsSerialNumbered = 1 
       GROUP BY 
        OrderProducts.ProductCode
    ) SerialNumberedProductCountsSubQuery 
    WHERE 
      SerialNumberedProductCountsSubQuery.Order_ID = Orders.Order_ID
  ) AS SerialNumberedProductCounts 
FROM 
  Orders

```

With the above query, I am getting the following error:

`ERROR 1054 (42S22): Unknown column 'Orders.Order_ID' in 'where clause'`