Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
linenumberstrue
SELECT t1.ValidFrom, t1.FromDate, t1.ToDate, t1.SorId, t1.ParentSorId, t1.HealthInstitutionSorId,
       t1.ProviderId, t1.ShakId, t1.EntityName, t1.InstitutionOwnerSorId,
       t1.InstitutionOwnerCvrNumberId, t1.EntityTypeId, t1.EntityTypeName
FROM SOR2SorEntity t1
JOIN (
        SELECT UniqueCurrentKey, MAX(ValidFrom) as MaxValidFrom
        FROM SOR2SorEntity
        WHERE FromDate >= :date_intervalcutoff
        OR (FromDate = 
                (
 	                SELECT MAX(FromDate)
                	FROM SOR2SorEntity t3
                	WHERE t3.SorId = SOR2SorEntity.SorId
                ) 
                AND (ToDate is NULL OR ToDate > :date_intervalcutoff)
        )
        GROUP BY UniqueCurrentKey
) t2 ON t1.UniqueCurrentKey = t2.UniqueCurrentKey AND t1.ValidFrom = t2.MaxValidFrom
;

Parameteren ":date_intervalcutoff" (linje 8) udfyldes med property "sores.retention.period" som beskrevet i driftsvejledningen.

...