 	SELECT vocabulary_pack.CutConceptName(d.term) AS concept_name,
 		d.conceptid::TEXT AS concept_code,
 		c.active,
-		MIN(c.effectivetime) OVER (
-			PARTITION BY c.id ORDER BY c.active DESC --if there ever were active versions of the concept, take the earliest one
+		FIRST_VALUE(c.effectivetime) OVER (
+			PARTITION BY c.id ORDER BY c.active DESC, c.effectivetime --if there ever were active versions of the concept, take the earliest one
 			) AS effectivestart,
 		ROW_NUMBER() OVER (
 			PARTITION BY d.conceptid

						THEN 4 -- SNOMED UK
					ELSE 99
					END ASC,
				l.effectivetime DESC
			) AS rn
	FROM sources.sct2_concept_full_merged c
	JOIN sources.sct2_desc_full_merged d ON d.conceptid = c.id

--Definition status id of the concept is “Fully defined”
--All concepts that sit in hierarchy between the concept and HoCFS/PHoP are “Fully defined”
--Attributes that define concept are limited to “has associated finding” & standard definitions
--! Check these concepts manually before insertion
with hist_of_value AS
(SELECT DISTINCT c.concept_code,
                 c.valid_start_date,
