simple query
Budget: €8 – €30 EUR
I have two tables with this key fields: doc_serie, doc_type and doc_number
table invoices holds the list of invoices
fields: doc_serie, doc_type, doc_number, custumer
table invoice_totals holds the totals
fields: doc_serie, doc_type and doc_number, total
The query:
select total from invoice_totals
where doc_serie=3 and doc_type=1 and doc_number=100
returns the corect total 17,55
but the query I bellow returns 21,38, what doesn't make any sense
what am I doing wrong?
select sum(invoice_totals.total)
from invoices
left join invoice_totals on invoice_totals.doc_serie=invoices.doc_serie and invoice_totals.doc_type=invoices.doc_type and invoice_totals.doc_number=invoices.doc_number
where
invoices.doc_serie=3 and invoices.doc_type=1 and invoices.doc_number=100
group by invoices.custumer
order by total desc
table invoices holds the list of invoices
fields: doc_serie, doc_type, doc_number, custumer
table invoice_totals holds the totals
fields: doc_serie, doc_type and doc_number, total
The query:
select total from invoice_totals
where doc_serie=3 and doc_type=1 and doc_number=100
returns the corect total 17,55
but the query I bellow returns 21,38, what doesn't make any sense
what am I doing wrong?
select sum(invoice_totals.total)
from invoices
left join invoice_totals on invoice_totals.doc_serie=invoices.doc_serie and invoice_totals.doc_type=invoices.doc_type and invoice_totals.doc_number=invoices.doc_number
where
invoices.doc_serie=3 and invoices.doc_type=1 and invoices.doc_number=100
group by invoices.custumer
order by total desc