But what's wrong with slimdave's suggestion?
select i.batch_id,
count(distinct i.invoice_id) invoice,
count(*)
from invoices i, invoice_lines il
where i.invoice_id = il.invoice_id
Less complicated query and will yield the expected output.
But shouldn't it also include a GROUP BY clause for the i.Batch_id column?!
select i.batch_id, count(distinct i.invoice_id) invoice,
count(*) from invoices i, invoice_lines il
where i.invoice_id = il.invoice_id
GROUP BY i.Batch_id
- Nandu
Re: But what's wrong with slimdave's suggestion?
Quote:
... shouldn't it also include a GROUP BY clause for the i.Batch_id column?! ...
pesky details! i suppose so.