I have an SQL that I need to group by one column only because the other columns may be different. Here is the SQL:
SELECT
INITCAP(PC_CATS.CAT_DESC) AS "Category",
TO_CHAR(DECODE(TRIM(SALES.SUNIT),'CS',SUM(SALES.QTY)*PC_DL.AVGWGT,DECODE(TRIM(SALES.SUNIT),'MT',SUM(SALES.QTY)*2204.6,
DECODE(TRIM(SALES.SUNIT),'KG',SUM(SALES.QTY)*2.2046,SUM(SALES.QTY)))),'999,999,999,999') as "LBS",
TO_CHAR(SUM(SALES.QTY), '9,999,999') || ' ' || SALES.SUNIT AS "Qty",
TO_CHAR(SUM(SALES.AMT), 'FML9,999,999') AS "Amt"
FROM SALES
LEFT JOIN PRODS ON SALES.PC = PRODS.PC
LEFT JOIN PC_DL ON PRODS.PC = PC_DL.PC
LEFT JOIN PC_CATS ON PRODS.PC_CAT = PC_CATS.PC_CAT
WHERE SALES.VEND = '$param_SupplierNumber' AND EXTRACT(YEAR FROM SALES.PDATE) = '$param_Year'
GROUP BY PC_CATS.CAT_DESC, SALES.SUNIT, PC_DL.AVGWGT
ORDER BY PC_CATS.CAT_DESC
What I am trying to accomplish is group all items under their respective PC_CATS.CAT_DESC (which is category) but each item can have a different SALES.SUNIT and a different PC_DL.AVGWGT. How can I only group by the PC_CATS.CAT_DESC?