(Richard Bos) wrote in message news:<>...
> (c_programmer) wrote:
>
> > I have a problem.
> > There is a effective dated list FAMILY_ACCOUNTS stored in the memory.
> > How to achieve the equivalent of the following SQL statement:
> >
> > select * from FAMILY_ACCOUNTS FA
> > where EFFECTIVE_DATE =
> > (select max(EFFECTIVE_DATE) from FAMILY_ACCOUNTS FA2 where
> > FA.FAMILY_ACCOUNTS_KEY = FA2.FAMILY_ACCOUNTS_KEY)
> > and EFFECTIVE_STATUS ="ACTIVE"
> > and EFFECTIVE_DATE <= given_date
> > and FAMILY_ACCOUNTS_KEY = given_key
> >
> > using bsearch and qsort?
>
> That's impossible to answer unless you tell us, quite precisely:
> - how FAMILY_ACCOUNTS is declared, in your C program;
> - what this SQL code does (I can tell that it selects something based on
> a set of requirements, but how, for example, does max() work?);
> - what the correspondence is between the elements of the SQL data set
> and your C objects.
>
> Richard
You don't know SQL?
FAMILY_ACCOUNT is some struct, that have EFFECTIVE_STATUS AC or DE,
EFFECTIVE_DATE i.e. 20050608 and some key i.e. Account No. For single
account we can have more then one row let say:
key1 20050601 AC
key1 20050603 AC
key1 20050605 AC
key1 20050607 DE
Our bsearch run with key1 and 20050602 should return row from 20050601
with key1 and 20060606 should return row from 20050605 and with key1
20050609 shouldn't return anything at all.