Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 31 Mar 2017 at 3:40am
i would use sql for that but it partly depends on if you are really wanting
1) the first record or the minimum date record
2) can there ever be an account with two days that are the same minimum date with two different 'numbers'
It is actually a Date/Time field. I used Date for simplicity of concept. I am interested in the NUMBER associated with the minimum DATETIME for the ACCOUNT.
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 31 Mar 2017 at 4:05am
maybe this...?
select t1.* from table1 t1
join (select Acct,MIN(Date) as MinDate from table1 group by Acct) as t2 on t1.acct=t2.Acct and t1.date = t2.MinDate
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 31 Mar 2017 at 4:16am
just joining the table to itself but on the 'second version' of the table doing a group by with the min date per acct. this limits the data rows to what you wanted. The join back gets you the unique 'number' value for that date from that acct.
This is what i tried using actual table names and fields. It was not happy. Input?
SELECT
dd.*
FROM Donor_Draw dd
JOIN (select donor_id,MIN(draw_start_datetime) as MinDate from Donor_Draw group by donor_id) as dd2 on dd.donor_id=dd2.donor_id and dd.draw_start_datetime = dd2.MinDate
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 31 Mar 2017 at 5:02am
and where did you do this?
this is a sql select statement, meaning it should be used as a view or stored proc in sql as the data source, or you can use it as a crystal command object as your data source
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum