Good day to all. I have three tables where I have to extract information on the customer (first table), checks issued to customer (2nd table), and supplementary checks issued (3rd table). Below is the sample of my query command:
SELECT a.CLAIM_NO, Name, b.d_issue, b.amount, b.check_no, c.d_issue, c.amount, c.check_no, c.reason
from customer_info a left join (select claim_no, d_issue, amount, check_no from checks_table
where d_issue between '01/01/1990' and '12/31/1994') b on a.claim_no = b.claim_no
left join (select claim_no, d_issue, check_no, amount, reason from supplementary_checks
where d_printed between '01/01/1990' and '12/31/1994') c on a.claim_no = c.claim_no
The query produces all checks issued and supplementary checks to the customer. However, in the Supplementary_Checks, if there is only 1 check for the customer, the info displayed are multiple redundant entries the same number as the number of info for the Checks_Table.
Below is my desired output:
Name b.D_Issue b.Amount b.Check_no c.D_issue c.Amount c.Check_no c.Reason
John Snow 01/01/2015 500.00 11111 02/10/2015 1000.00 12123 Payment for...
02/01/2015 500.00 22222
03/01/2015 500.00 33333
04/01/2015 500.00 44444
Hope somebody can provide me a solution because I am stuck in my query for a couple days now. Thanks in advance to all.