BrianTyler
IS-IT--Management
I frequently have to write queries such as:
select
a.custno,a.payref,a.payamt
from
tab a
where
a.payref =
(select
max(b.payref)
from
tab b
where
b.custno = a.custno and
b.paytype = 1)
This query should give details of the latest payment of type 1 for a particular customer.
Is there a more streamlined approach to this problem?
Regards
Brian
select
a.custno,a.payref,a.payamt
from
tab a
where
a.payref =
(select
max(b.payref)
from
tab b
where
b.custno = a.custno and
b.paytype = 1)
This query should give details of the latest payment of type 1 for a particular customer.
Is there a more streamlined approach to this problem?
Regards
Brian