I have two tables, table A contains date, type & transid
table B contains invoiceid and transid.
I need to get a count of invoices from table b by day where the newest transaction in table a is of type='M' (grouping by tableb.headerid).
My basic select to find transactions containing M types is:
select a.type, a.date, b.invoiceid
from
a, b
where a.transid=b.transid
and a.type='M'
After this point, it gets pretty foggy for me:
Throwing in a 'group by invoiceid' seems to keep me from being able to get the actual a.type from the table, rather I am forced to do something like count, etc.
eg:
select count(a.type), max(a.date), b.invoiceid
from a,b
where a.transid=b.transid
and a.type='M'
group by b.invoiceid
I was thinking I could create a loop to read through each grouping, but I'm just at a loss as to where to start. Any help would be greatly appreciated!!
Thanks.
table B contains invoiceid and transid.
I need to get a count of invoices from table b by day where the newest transaction in table a is of type='M' (grouping by tableb.headerid).
My basic select to find transactions containing M types is:
select a.type, a.date, b.invoiceid
from
a, b
where a.transid=b.transid
and a.type='M'
After this point, it gets pretty foggy for me:
Throwing in a 'group by invoiceid' seems to keep me from being able to get the actual a.type from the table, rather I am forced to do something like count, etc.
eg:
select count(a.type), max(a.date), b.invoiceid
from a,b
where a.transid=b.transid
and a.type='M'
group by b.invoiceid
I was thinking I could create a loop to read through each grouping, but I'm just at a loss as to where to start. Any help would be greatly appreciated!!
Thanks.