My problem is that my transaction table can contain 1 or more lines for the same product for a customer. I need to make a subquery that will, by customer, sum the quantity for like products and then extract the all of the information for the product with the largest quantity so it can be used in the query above the subquery. The subquery below gives me one line per product(symbol). How do I query this to get ALL of the fields for the first line (largest quantity) of each customer group. Each customer group will contain many different products.
SELECT ACCOUNT_NB, SYMBOL, SUM(QUANTITY) QTY, PRICE, PRICE * SUM(QUANTITY) VALUE
FROM STG_SIS_PRICE
GROUP BY ACCOUNT_NB, SYMBOL, TR_DATE, PRICE
ORDER BY ACCOUNT_NB, SUM(QUANTITY) DESC
SELECT ACCOUNT_NB, SYMBOL, SUM(QUANTITY) QTY, PRICE, PRICE * SUM(QUANTITY) VALUE
FROM STG_SIS_PRICE
GROUP BY ACCOUNT_NB, SYMBOL, TR_DATE, PRICE
ORDER BY ACCOUNT_NB, SUM(QUANTITY) DESC