Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 *

Author  Topic 

wtrihardiny
Starting Member

12 Posts

Posted - 2008-06-16 : 11:33:11
*

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 11:38:13
[code]select cp.clientpolicyno, cp.baseclaimID,
sc.effectivedate as StatusChangeDate
from claimpolicy cp
join StatusChange sc
on sc.ownerOID = cp.BaseClaimID
and sc.OwnerTypeCode = 70
join (select ownerOID,max(EffectiveDate) as maxdate
from StatusChange
where OwnerTypeCode = 70
Group BY ownerOID) t
ON t.ownerOID=sc.ownerOID
AND t.maxdate=sc.EffectiveDate

where cp.clientpolicyno = 88710575 [/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 11:51:44
[code]SELECT t.clientpolicyno, t.baseclaimID,t.StatusChangeDate
FROM
(
select ROW_NUMBER() OVER(PARTITION BY cp.clientpolicyno ORDER BY sc.effectivedate DESC) AS RowNo,
cp.clientpolicyno, cp.baseclaimID,
sc.effectivedate as StatusChangeDate
from claimpolicy cp
join StatusChange sc
on sc.ownerOID = cp.BaseClaimID
and sc.OwnerTypeCode = 70
where cp.clientpolicyno = 88710575
)t
WHERE t.RowNo=1[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 12:02:35
[code]select cp.clientpolicyno,
MIN(cp.baseclaimID),
MIN(sc.effectivedate) as StatusChangeDate
from claimpolicy cp
join StatusChange sc
on sc.ownerOID = cp.BaseClaimID
and sc.OwnerTypeCode = 70
join (select cp1.clientpolicyno,max(sc1.EffectiveDate) as maxdate
from claimpolicy cp1
join StatusChange sc1
on sc1.ownerOID = cp1.BaseClaimID
and sc1.OwnerTypeCode = 70
Group by cp1.clientpolicyno
) t
ON t.clientpolicyno=cp.clientpolicyno
AND t.maxdate=sc.EffectiveDate
where cp.clientpolicyno = 88710575
GROUP BY cp.clientpolicyno[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 12:49:30
quote:
Originally posted by wtrihardiny

YAY!!! IT WORKED!!! THANK YOU SO MUCH VISAKH16! YOU ARE THE BEST!


You're welcome
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-11-18 : 10:09:36
great.. now we just need to guess what he was doing

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-11-18 : 10:31:00
Guess he waited till now to delete the original post to make sure it was no longer in Google cache.




CODO ERGO SUM
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-18 : 11:13:27
I really cant understand what these people gain from deleting their original questions?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-18 : 16:12:18
Also see
http://education.sqlfarms.com/education/ShowPost.aspx?PostID=1606
http://education.sqlfarms.com/education/ShowPost.aspx?PostID=1646
http://education.sqlfarms.com/education/ShowPost.aspx?PostID=1661
http://education.sqlfarms.com/education/ShowPost.aspx?PostID=1662
http://education.sqlfarms.com/education/ShowPost.aspx?PostID=1711


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -