Hi!
I have this table:
IDNR FOM TYP TOM
1000 2003-mar-31
1000 2003-mar-31 T 2003-apr-30
1000 2003-feb-11 2003-mar-30
1010 2003-mar-31
1020 2003-mar-31 T 2003-apr-30
1020 2003-mar-31 2003-apr-30
1030 2003-mar-31
1030 2003-feb-11 2003-apr-30
If I run the query on april 29 I want this result:
IDNR FOM TYP TOM
1000 2003-mar-31 T 2003-apr-30
1010 2003-mar-31
1020 2003-mar-31 T 2003-apr-30
1030 2003-feb-11 2003-apr-30
I want only one record per IDNR. If the runningdate is between FOM and TOM and TYP=T then that record should be returned. If TYP != T and the runningdate is between FOM and TOM then this record is correct, bot only if the first condition isn't met. If FOM is before the runningdate and TOM is null theh that record should be returned, but only if the first two conditions fail
Any idea anyone?
Thank you
/Fredrik
I have this table:
IDNR FOM TYP TOM
1000 2003-mar-31
1000 2003-mar-31 T 2003-apr-30
1000 2003-feb-11 2003-mar-30
1010 2003-mar-31
1020 2003-mar-31 T 2003-apr-30
1020 2003-mar-31 2003-apr-30
1030 2003-mar-31
1030 2003-feb-11 2003-apr-30
If I run the query on april 29 I want this result:
IDNR FOM TYP TOM
1000 2003-mar-31 T 2003-apr-30
1010 2003-mar-31
1020 2003-mar-31 T 2003-apr-30
1030 2003-feb-11 2003-apr-30
I want only one record per IDNR. If the runningdate is between FOM and TOM and TYP=T then that record should be returned. If TYP != T and the runningdate is between FOM and TOM then this record is correct, bot only if the first condition isn't met. If FOM is before the runningdate and TOM is null theh that record should be returned, but only if the first two conditions fail

Thank you
/Fredrik