Page History
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
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_cutoff OR (FromDate = ( SELECT MAX(FromDate) FROM SOR2SorEntity t3 WHERE t3.SorId = SOR2SorEntity.SorId AND FromDate <= :date_cutoff ) AND (ToDate is NULL OR ToDate > :date_cutoff) ) GROUP BY UniqueCurrentKey ) t2 ON t1.UniqueCurrentKey = t2.UniqueCurrentKey AND t1.ValidFrom = t2.MaxValidFrom ; |
...