NEED SOME HELP!! I've created the query below. I need a query that will look in a table and if intCaseID is null, then will pull a date in another table, else will pull a date in that table.
Right now it only works one way if the value is not null, it works correctly. If its null, then it doesn't pull the value in t.dteTransaction.
SELECT
(CASE when d.intCaseID is null then MAX(t.dteTransaction)
ELSE MAX(d.dtePosted) END) As dte
FROM tblTransaction t
INNER JOIN
tblBankAccount b
ON b.intAccountID = t.intAccountID
INNER JOIN
tblDistribution d
ON d.intCaseID = b.intCaseID
GROUP BY d.intCaseID, b.intCaseID, d.intPosted, b.intDeleted, d.intDeleted, t.intDeleted,
t.intTransactionMethod
HAVING
(b.intCaseID = 468267)
AND d.intPosted = 1
AND b.intDeleted = 0
AND d.intDeleted = 0
AND t.intDeleted = 0
AND t.intTransactionMethod = 124
Right now it only works one way if the value is not null, it works correctly. If its null, then it doesn't pull the value in t.dteTransaction.
SELECT
(CASE when d.intCaseID is null then MAX(t.dteTransaction)
ELSE MAX(d.dtePosted) END) As dte
FROM tblTransaction t
INNER JOIN
tblBankAccount b
ON b.intAccountID = t.intAccountID
INNER JOIN
tblDistribution d
ON d.intCaseID = b.intCaseID
GROUP BY d.intCaseID, b.intCaseID, d.intPosted, b.intDeleted, d.intDeleted, t.intDeleted,
t.intTransactionMethod
HAVING
(b.intCaseID = 468267)
AND d.intPosted = 1
AND b.intDeleted = 0
AND d.intDeleted = 0
AND t.intDeleted = 0
AND t.intTransactionMethod = 124