 				CASE 
 					WHEN MULTI_NONPROPRIETARYNAME IS NULL
 						THEN CONCAT (
-								substr(nonproprietaryname, 1, 100),
+								SUBSTR(nonproprietaryname, 1, 100),
 								CASE 
 									WHEN length(nonproprietaryname) > 100
 										THEN '...'
 									END,
-								NULLIF(' ' || substr(aggr_dose, 1, 100), ' '),
+								NULLIF(' ' || SUBSTR(aggr_dose, 1, 100), ' '),
 								' ',
-								substr(routename, 1, 100),
+								SUBSTR(routename, 1, 100),
 								' ',
-								substr(dosageformname, 1, 100)
+								SUBSTR(dosageformname, 1, 100)
 								)
 					ELSE CONCAT (
 							'Multiple formulations: ',
-							substr(nonproprietaryname, 1, 100),
+							SUBSTR(nonproprietaryname, 1, 100),
 							CASE 
 								WHEN length(nonproprietaryname) > 100
 									THEN '...'
 								END,
-							NULLIF(' ' || substr(aggr_dose, 1, 100), ' '),
+							NULLIF(' ' || SUBSTR(aggr_dose, 1, 100), ' '),
 							' ',
-							substr(routename, 1, 100),
+							SUBSTR(routename, 1, 100),
 							' ',
-							substr(dosageformname, 1, 100)
+							SUBSTR(dosageformname, 1, 100)
 							)
 					END AS concept_name,
 				SUBSTR(brand_name, 1, 255) AS brand_name,

	valid_end_date,
	invalid_reason
	)
SELECT SUBSTR(concept_name, 1, 255) AS concept_name,
	'Drug' AS domain_id,
	'NDC' AS vocabulary_id,
	'11-digit NDC' AS concept_class_id,

	SELECT concept_code,
		coalesce(startdate, min(l.ndc_valid_start_date)) valid_start_date,
		coalesce(enddate, max(h.ndc_valid_end_date)) valid_end_date,
		TRIM(SUBSTR(coalesce(c_name1, c_name2, max(spl_name)), 1, 255)) concept_name
	FROM (
		SELECT n.concept_code,
			n.startdate,
