rogerzebra
Technical User
Hi,
I have a problem with a multiple subquery and I was hoping that someone could help me out on this one. I’m trying to filter out duplicated policies from my list so they just beeing counted once. The first subselect filters out policies with several transactions and using max (date) shows policies with from the most reasant date.
The problem I have is when a policy has more than one transaction on the same day. Each policy has a transaction number and its increases each time the policy has changed. So my next subselect sorts out all policies except for the one with the highest transaction number. The query works, but my problem is that my transaction date column gives me a lot of nulls in the end result??
Here is my code
I would appreciate if someone can point out what I'm doing wrong here.
Thanks
/r
I have a problem with a multiple subquery and I was hoping that someone could help me out on this one. I’m trying to filter out duplicated policies from my list so they just beeing counted once. The first subselect filters out policies with several transactions and using max (date) shows policies with from the most reasant date.
The problem I have is when a policy has more than one transaction on the same day. Each policy has a transaction number and its increases each time the policy has changed. So my next subselect sorts out all policies except for the one with the highest transaction number. The query works, but my problem is that my transaction date column gives me a lot of nulls in the end result??
Here is my code
Code:
Select Policies
,a.transactiondt
,a.transactionNumber
FROM table1 b
left join table2 a
on b.Id = a.Id
and a.SystemId = b.SystemId
and TransactionDates =
(
select max(c.TransactionDates)
from table2 c
where c.SystemID = a.SystemId
)
and TransactionNumber = (
select max(d.TransactionNumber)
from table2 d
where d.SystemID = a.SystemID
)
WHERE ….
Thanks
/r