We help IT Professionals succeed at work.
Get Started

Subsequent question regarding previous successful answer

Roslan Ramli
Roslan Ramli asked
Last Modified: 2012-05-09
The question on the link below was answered

but now need together with the output, the breakdown of the payments so that with the data results I could process it to produce a statement. I got a query below but not working as expected. It sums up the invoices for all payments and hence we get invoices twice the value if 2 payments are made. Even then it shows only 1 payment.

<output name="c.name" title="Name" />,
<output name="c.reference" title="Reference No." />,
<output replace="i.idinvoice" title="Invoice ID" />,
<output replace="(SUM(v.quantity * s.charges))" />AS Invoice,
<output replace="(p.amount)" data="float" />As Amount,
<output name="p.idpayment" title="Payment ID" />,
<output replace="p.cheque_no" title="Cheque No" />,
<output replace="p.pdatetime" title="Processed Time" />,
<output replace="p.user" title="Processed By" type="user" attribute="username" />
FROM inv i
LEFT JOIN invitem v ON v.idinvoice = i.idinvoice
LEFT JOIN service s ON s.idservice = v.idservice
LEFT JOIN payment p ON i.idinvoice = p.idinvoice
LEFT JOIN address a ON a.idaddress = i.idaddress
LEFT JOIN client c ON c.idclient = a.idclient
WHERE a.idaddress = '<input name="idaddress" />'
GROUP BY i.idinvoice
ORDER BY i.idinvoice DESC
Watch Question
Expert of the Quarter 2010
Expert of the Year 2010
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE