Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding claims after the status 'case closed'

Status
Not open for further replies.

zuza

Programmer
Nov 9, 2003
54
YU
Dear all,

I will start wil an example, it is a table with history like:

Claimno ---- Status ---- Datest
ds001123 notified 12/01/04
ds001123 Case closed 12/03/04
ds001123 decision 12/09/04

By the rule 'Case closed' should be the last status, so how to find records like one above, that after the case closed is entered status ('decision', in this case) with higher date and it shoul be before the status 'case closed'

I you understood me, I hope that you will help me.

Rgds,
ZuZa
 
You can do something like this:

Code:
select tt1.* 
from
	#tmpTest tt1
	inner join #tmpTest tt2 on tt1.MyID = tt2.MyID
where
	tt1.Status = 'Case Closed'
	and tt1.StatusDate < tt2.StatusDate
 
Code:
select	a.*
from	yourTable as a
where	a.datest = (select max(datest)
			from yourTable as b
			where	a.claimno = b.claimno)
and	Status <> 'Case closed'

Reality of a dreameR.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top