Oops I think I was trying to combine 2 thoughts into one....I think what I
meant was
select *
from invoice_status
where created in
(select max(created) from invoice_status group by invoiceID)
and status=1
two problems:
1) mysql doesn't do subquerys (so build a string with the subquery)
2) won't be 100% accurate if 2 invoices have the same exact status change
date and one of them has a later status change that is not 1 (how likely
is that?)
but I think even though you have to do 2 queries it might be faster than
looping? maybe?
--
Christie Walker
On Wed, 12 Jul 2000, Leon Atkinson wrote:
> > > > SELECT Invoice
> > > > FROM invoice_status
> > > > WHERE Status=1 AND Created=MAX(Created)
> > > > GROUP BY Invoice
> > > >
> > > > But couldn't get it to work. "Invalid use of group function"
> > >
> > > You need ORDER BY, not GROUP BY.
> >
> > I cant get this example to work either.
> > I used ORDER BY instead of GROUP BY.
>
> OK, sorry. I didn't read through it well enough. Of course it won't work.
> You can't put MAX() in a WHERE clause.
>
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Site: http://www.working-dogs.com/freetrade/
Problems?: [EMAIL PROTECTED]