I HAVE THIS QUERY:
SELECT DIMENSIONS.DESCRIPTION, HOS_SALEHST.CUSTOMERCLASS, MONTH (HOS_SALEHST.INVOICEDATE) as MONTH,
YEAR (HOS_SALEHST.INVOICEDATE) as YEAR, HOS_SALEHST.ITEMCLASS, SUM(HOS_SALEHST.QUANTITY) AS QUANTITY, SUM(HOS_SALEHST.NETSALESAMOUNT)
AS NETSALESAMOUNT
FROM HOS_SALEHST INNER JOIN
DIMENSIONS ON HOS_SALEHST.DATAAREAID = DIMENSIONS.DATAAREAID AND HOS_SALEHST.ITEMCLASS = DIMENSIONS.NUM
WHERE (HOS_SALEHST.INVOICEDATE >= '1/1/2013') AND (HOS_SALEHST.INVOICEDATE < '4/1/2014') AND (HOS_SALEHST.ITEMCLASS <= 1985) AND
(HOS_SALEHST.ITEMCLASS <> '') AND (DIMENSIONS.DIMENSIONCODE = 1) AND ((HOS_SALEHST.COMPANYNUM >= 02 AND
HOS_SALEHST.COMPANYNUM <= 07 AND
HOS_SALEHST.CUSTOMERCLASS = 'DS') OR
(HOS_SALEHST.COMPANYNUM = 01 AND
HOS_SALEHST.CUSTOMERCLASS <> 'DC'))
GROUP BY HOS_SALEHST.CUSTOMERCLASS,HOS_SALEHST.ITEMCLASS, DIMENSIONS.DESCRIPTION, MONTH(HOS_SALEHST.INVOICEDATE), YEAR(HOS_SALEHST.INVOICEDATE)
ORDER BY HOS_SALEHST.ITEMCLASS
I want to have it where the SALEHST.CUSTOMERCLASS will pull in the lines t that are 'ES' or 'EC' as EXP but all others pull in as they are.
I tried using the CASE ELSE below but can't get it to work. Maybe it's not the right approach???
SELECT DIMENSIONS.DESCRIPTION, HOS_SALEHST.CUSTOMERCLASS, MONTH (HOS_SALEHST.INVOICEDATE) as MONTH,
YEAR (HOS_SALEHST.INVOICEDATE) as YEAR, HOS_SALEHST.ITEMCLASS, SUM(HOS_SALEHST.QUANTITY) AS QUANTITY, SUM(HOS_SALEHST.NETSALESAMOUNT)
AS NETSALESAMOUNT
FROM HOS_SALEHST INNER JOIN
DIMENSIONS ON HOS_SALEHST.DATAAREAID = DIMENSIONS.DATAAREAID AND HOS_SALEHST.ITEMCLASS = DIMENSIONS.NUM
WHERE (HOS_SALEHST.INVOICEDATE >= '1/1/2013') AND (HOS_SALEHST.INVOICEDATE < '4/1/2014') AND (HOS_SALEHST.ITEMCLASS <= 1985) AND
(HOS_SALEHST.ITEMCLASS <> '') AND (DIMENSIONS.DIMENSIONCODE = 1) AND ((HOS_SALEHST.COMPANYNUM >= 02 AND
HOS_SALEHST.COMPANYNUM <= 07 AND
HOS_SALEHST.CUSTOMERCLASS = 'DS') OR
(HOS_SALEHST.COMPANYNUM = 01 AND
HOS_SALEHST.CUSTOMERCLASS <> 'DC',
CASE SALEHST.CUSTOMERCLASS
WHEN 'EC' OR 'ES' THEN 'EXP'
ELSE 'SALEHST.CUSTOMERCLASS'))
GROUP BY HOS_SALEHST.CUSTOMERCLASS,HOS_SALEHST.ITEMCLASS, DIMENSIONS.DESCRIPTION, MONTH(HOS_SALEHST.INVOICEDATE), YEAR(HOS_SALEHST.INVOICEDATE)
ORDER BY HOS_SALEHST.ITEMCLASS
Really appreciate your help.