Hi guys I tried to to use inner join on 5 tables it worked but the problem is instead of getting the exact sum values it got doubled. Here's my code
cmd = New OleDbCommand("SELECT om_list.invoice_no as invoice_no, om_list.internal_id as internal_id, om_list.customer_id as customer_id, om_list.account_name as account_name, om_list.seller_name as seller_name, om_list.terms as terms, om_list.date_invoice as date_invoice, cancel_discount.date_deliver as date_deliver, om_list.segment as segment, sum(cancel_discount.invoice_amnt) as invoice_amnt, sum(app_deduc_rgpi.amount) as rgpi_deduction, sum(app_deduc_mda.amount) as mda_deduction, rgpi_deduction + mda_deduction AS total_deduction, sum(payment_applied.payment_applied) as payment_applied FROM (om_list Inner Join (payment_applied Inner Join cancel_discount on payment_applied.invoice_no = cancel_discount.invoice_no) on om_list.invoice_no = payment_applied.invoice_no) Inner Join (app_deduc_rgpi Inner Join app_deduc_mda on app_deduc_rgpi.invoice_no = app_deduc_mda.invoice_no) on om_list.invoice_no = app_deduc_rgpi.invoice_no group by om_list.invoice_no, om_list.internal_id, om_list.customer_id, om_list.account_name, om_list.seller_name, om_list.segment, om_list.terms, om_list.date_invoice, cancel_discount.date_deliver", con)
con.Open()
adpt = New OleDbDataAdapter(cmd)
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(adpt)
dtset = New DataSet()
adpt.Fill(dtset)
con.Close()
I didn't know if I should post it here or on SQL though I made it in VB so I'm gonna post it here. If it's inapporpriate please transfer it to the proper section