Subject | Re: [ib-support] How do I formulate this... |
---|---|
Author | Svein Erling Tysvær |
Post date | 2002-03-19T13:02:30Z |
Hi Dave!
If there are no duplicate records on the same date, the only problem I see
is that it could be a rather slow select.
I think
SELECT *
FROM CONTACTHISTORY A
WHERE NOT EXISTS (SELECT 1
FROM CONTACTHISTORY B
WHERE B.CONTACTTYPEID = A.CONTACTTYPEID
AND B.CONTACTDATE > A.CONTACTDATE)
could be considerably faster. Try for yourself. If it is a large table,
make sure you've got an index on (CONTACTTYPEID, CONTACTDATE DESC).
Set
If there are no duplicate records on the same date, the only problem I see
is that it could be a rather slow select.
I think
SELECT *
FROM CONTACTHISTORY A
WHERE NOT EXISTS (SELECT 1
FROM CONTACTHISTORY B
WHERE B.CONTACTTYPEID = A.CONTACTTYPEID
AND B.CONTACTDATE > A.CONTACTDATE)
could be considerably faster. Try for yourself. If it is a large table,
make sure you've got an index on (CONTACTTYPEID, CONTACTDATE DESC).
Set
>I forgot to say I'm using FB 1.0
>This seems to work...
>
>select * from contacthistory A where
> A.contactdate in (select max(contactdate) from contacthistory b where
>a.contacttypeid = b.contacttypeid)
>
>Can any one spot any problems?