Subject RE: [firebird-support] group by ??
Author Svein Erling Tysvær
Hi Dany!

If I remember correctly, you are using Firebird 2.1. Then I would expect something like

SELECT m2.MOVI, m2.PROC, m2.DSCR, m2.FECH, m2.HORA
FROM (select m.PROC, max(m.FECH) from MOVI m group by m.PROC) ms
JOIN MOVI m2 on ms.PROC = m2.proc and ms.FECH = m2.FECH

to work. Though, still being on Fb 1.5 myself, I've no idea whether it will be any faster than the NOT EXISTS that has been suggested to you (I kind of doubt it).

Set

-----Original Message-----
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of danyschaer
Sent: 9. juni 2008 16:26
To: firebird-support@yahoogroups.com
Subject: [firebird-support] group by ??

Hi All;

I have a table named MOVI with (as an example) this fields:

MOVI Char(10)
PROC Char(10)
DSCR Char(10)
FECH Char(8)
HORA Char(4)
DSCR Varchar(200)

I have to obtain all the fields for each record that is the MAX(FECH)
from groups of PROC:

select "PROC", max("FECH") from "MOVI" group by "PROC"

Like this, but I have to get all the fields. How can I do that?.

Thank you!

Dany