I created a query and now I need to use the results from that query to get more detailed results. Any suggestions!
1st Query:
SELECT
c.vchTrustee, COUNT(ba.vchAccountNumber) AS total, ba.vchAccountNumber
FROM
tblBankAccount ba
INNER JOIN tblCase c ON
ba.intcaseID = c.intCaseID
GROUP BY c.vchTrustee, ba.vchAccountNumber, ba.intDeleted, c.intDeleted
HAVING
COUNT(ba.vchAccountNumber) > 1
AND ba.intDeleted = 0
AND c.intDeleted = 0
ORDER by c.vchTrustee, ba.vchAccountNumber
Then I need to take those results and select detailed information for each record that exists with the same ba.vchAccountNumber > 1
SELECT
c.vchTrustee, ba.vchAccountNumber, ba.dteCreated, ba.vchCreatedBy
FROM
tblBankAccount ba
INNER JOIN tblCase c ON
ba.intcaseID = c.intCaseID
WHERE ba.intDeleted = 0
AND c.intDeleted = 0
ORDER by c.vchTrustee, ba.vchAccountNumber
1st Query:
SELECT
c.vchTrustee, COUNT(ba.vchAccountNumber) AS total, ba.vchAccountNumber
FROM
tblBankAccount ba
INNER JOIN tblCase c ON
ba.intcaseID = c.intCaseID
GROUP BY c.vchTrustee, ba.vchAccountNumber, ba.intDeleted, c.intDeleted
HAVING
COUNT(ba.vchAccountNumber) > 1
AND ba.intDeleted = 0
AND c.intDeleted = 0
ORDER by c.vchTrustee, ba.vchAccountNumber
Then I need to take those results and select detailed information for each record that exists with the same ba.vchAccountNumber > 1
SELECT
c.vchTrustee, ba.vchAccountNumber, ba.dteCreated, ba.vchCreatedBy
FROM
tblBankAccount ba
INNER JOIN tblCase c ON
ba.intcaseID = c.intCaseID
WHERE ba.intDeleted = 0
AND c.intDeleted = 0
ORDER by c.vchTrustee, ba.vchAccountNumber