The following code works fine when I run it with ONLY the blue code.
SELECT
PRPMED.NCONO AS COMPANY,
PRPMED.NSSNO AS SSN,
PRPMED.NEENO AS EMP_NO,
PRPMED.NAMDE AS DEDN_AMT,
PRPMED.NDENO AS DEDN_NO,
PRPMED.NDTJR AS JNRL_DATE,
HRPMBN.MNAMDE AS BENE_MATCH_AMT,
HRPMBN.MNBNTY AS BENE_TYPE,
HRPMBN.MNBNNO AS BENE_NUM ,
Sum(CASE WHEN HRPMBN.MNBNTY = 2 THEN HRPMBN.MNAMDE END) AS Contrib
FROM PRPMED LEFT JOIN HRPMBN ON
(PRPMED.NCONO = HRPMBN.MNCONO) AND
(PRPMED.NSSNO = HRPMBN.MNSSNO) AND
(PRPMED.NEENO = HRPMBN.MNEENO)
WHERE
PRPMED.NDTJR = @variable('Journal Date (yyyymmdd)') and
HRPMBN.MNDTJR = @variable('Journal Date (yyyymmdd)') AND
(PRPMED.NDENO in (20,21,22,701,702,703) OR
HRPMBN.MNBNNO in (401,410))
GROUP BY PRPMED.NCONO, PRPMED.NSSNO, PRPMED.NEENO
When I add just the red section I get an error message "[IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0122 - Column NCONO or expression in SELECT list not valid.-122"
When I add the red AND green sections I get an error message "[IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0122 - Column NAMDE or expression in SELECT list not valid.-122"
Can anybody please tell me what I'm doing wrong?
SELECT
PRPMED.NCONO AS COMPANY,
PRPMED.NSSNO AS SSN,
PRPMED.NEENO AS EMP_NO,
PRPMED.NAMDE AS DEDN_AMT,
PRPMED.NDENO AS DEDN_NO,
PRPMED.NDTJR AS JNRL_DATE,
HRPMBN.MNAMDE AS BENE_MATCH_AMT,
HRPMBN.MNBNTY AS BENE_TYPE,
HRPMBN.MNBNNO AS BENE_NUM ,
Sum(CASE WHEN HRPMBN.MNBNTY = 2 THEN HRPMBN.MNAMDE END) AS Contrib
FROM PRPMED LEFT JOIN HRPMBN ON
(PRPMED.NCONO = HRPMBN.MNCONO) AND
(PRPMED.NSSNO = HRPMBN.MNSSNO) AND
(PRPMED.NEENO = HRPMBN.MNEENO)
WHERE
PRPMED.NDTJR = @variable('Journal Date (yyyymmdd)') and
HRPMBN.MNDTJR = @variable('Journal Date (yyyymmdd)') AND
(PRPMED.NDENO in (20,21,22,701,702,703) OR
HRPMBN.MNBNNO in (401,410))
GROUP BY PRPMED.NCONO, PRPMED.NSSNO, PRPMED.NEENO
When I add just the red section I get an error message "[IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0122 - Column NCONO or expression in SELECT list not valid.-122"
When I add the red AND green sections I get an error message "[IBM][iSeries Access ODBC Driver][DB2 UDB]SQL0122 - Column NAMDE or expression in SELECT list not valid.-122"
Can anybody please tell me what I'm doing wrong?