dndaughtery
Programmer
I have the following query that I'm using but I get nothing back. I've checked the "rejects" table and there are records there. The query is:
SELECT ' ' AS [Auth Code],
CardPreferredQry.BankName,
CardPreferredQry.ABA AS ROUTING,
Right(RTRIM(LTRIM(CardPreferredQry.ACCT)), 6) AS [ACCT#],
Rejects.rejectamount AS Amount,
' ' AS [CHK#],
Card.CH_LNAME AS LASTNAME,
Card.CH_FNAME AS FIRSTNAME,
Card.CH_HADDR1 AS ADDRESS,
Card.CH_HADDR2 AS ADDRESS2,
Card.CH_HCITY AS CITY,
Card.CH_HSTATE AS STATE,
Card.CH_HZIP AS ZIP,
Card.CH_HPHONE AS PHONE,
Right(RTRIM(LTRIM(Card.CH_SSN)), 4)AS SSN,
Card.CH_WADDR1,
Card.CH_WADDR2,
Card.CH_WCITY,
Card.CH_WSTATE,
Card.CH_WZIP,
Card.CH_WPHONE,
Card.DL_STATE,
Card.DL_NUM,
'NI52000' AS [CLIENT#],
Rejects.rejectdate AS [DATE DEBITED],
Rejects.rejectcode,
RejectCodes.RejectName AS [RETURN REASON],
Rejects.SentToCollections,
Rejects.rejectid,
COALESCE([Merchant].[M_NAME],[Program].[ProgramName]) AS [Name],
Merchant.M_FNAME,
Merchant.M_LNAME,
Merchant.M_ADDR1,
Merchant.M_ADDR2,
Merchant.M_CITY,
Merchant.M_STATE,
Merchant.M_ZIP,
Merchant.M_PHONE,
Merchant.FaxNumber,
Merchant.EmailAddress,
Location.L_NAME,
Location.L_ADDR1,
Location.L_ADDR2,
Location.L_City,
Location.L_State,
Location.L_Zip,
Location.Fax,
Location.EmailAddr,
GetDate() As [Date],
Card.AccountNumber,
Rejects.ProgramID,
Rejects.CollectionAgencyID
FROM (Rejects LEFT JOIN RejectCodes ON Rejects.rejectcode = RejectCodes.RejectCode )
LEFT JOIN Location ON Rejects.LocationID = Location.LocationID
LEFT JOIN (Card LEFT JOIN CardPreferredQry ON Card.CardID = CardPreferredQry.CardID) ON Rejects.CardID = Card.CardID
LEFT JOIN Disburse ON Rejects.DisburseID = Disburse.DisburseID
LEFT JOIN Merchant ON Disburse.MerchantID = Merchant.MerchantID
INNER JOIN Program ON Rejects.ProgramID = Program.ProgramID
INNER JOIN RejectCollectable_V_EC ON Rejects.rejectid = RejectCollectable_V_EC.rejectid
WHERE Rejects.CollectionAgencyID=1
What am I doing wrong?
SELECT ' ' AS [Auth Code],
CardPreferredQry.BankName,
CardPreferredQry.ABA AS ROUTING,
Right(RTRIM(LTRIM(CardPreferredQry.ACCT)), 6) AS [ACCT#],
Rejects.rejectamount AS Amount,
' ' AS [CHK#],
Card.CH_LNAME AS LASTNAME,
Card.CH_FNAME AS FIRSTNAME,
Card.CH_HADDR1 AS ADDRESS,
Card.CH_HADDR2 AS ADDRESS2,
Card.CH_HCITY AS CITY,
Card.CH_HSTATE AS STATE,
Card.CH_HZIP AS ZIP,
Card.CH_HPHONE AS PHONE,
Right(RTRIM(LTRIM(Card.CH_SSN)), 4)AS SSN,
Card.CH_WADDR1,
Card.CH_WADDR2,
Card.CH_WCITY,
Card.CH_WSTATE,
Card.CH_WZIP,
Card.CH_WPHONE,
Card.DL_STATE,
Card.DL_NUM,
'NI52000' AS [CLIENT#],
Rejects.rejectdate AS [DATE DEBITED],
Rejects.rejectcode,
RejectCodes.RejectName AS [RETURN REASON],
Rejects.SentToCollections,
Rejects.rejectid,
COALESCE([Merchant].[M_NAME],[Program].[ProgramName]) AS [Name],
Merchant.M_FNAME,
Merchant.M_LNAME,
Merchant.M_ADDR1,
Merchant.M_ADDR2,
Merchant.M_CITY,
Merchant.M_STATE,
Merchant.M_ZIP,
Merchant.M_PHONE,
Merchant.FaxNumber,
Merchant.EmailAddress,
Location.L_NAME,
Location.L_ADDR1,
Location.L_ADDR2,
Location.L_City,
Location.L_State,
Location.L_Zip,
Location.Fax,
Location.EmailAddr,
GetDate() As [Date],
Card.AccountNumber,
Rejects.ProgramID,
Rejects.CollectionAgencyID
FROM (Rejects LEFT JOIN RejectCodes ON Rejects.rejectcode = RejectCodes.RejectCode )
LEFT JOIN Location ON Rejects.LocationID = Location.LocationID
LEFT JOIN (Card LEFT JOIN CardPreferredQry ON Card.CardID = CardPreferredQry.CardID) ON Rejects.CardID = Card.CardID
LEFT JOIN Disburse ON Rejects.DisburseID = Disburse.DisburseID
LEFT JOIN Merchant ON Disburse.MerchantID = Merchant.MerchantID
INNER JOIN Program ON Rejects.ProgramID = Program.ProgramID
INNER JOIN RejectCollectable_V_EC ON Rejects.rejectid = RejectCollectable_V_EC.rejectid
WHERE Rejects.CollectionAgencyID=1
What am I doing wrong?