SELECT
DISTINCT ON ("PLT_CN")
*
FROM "FIA_COND"
;

ALTER TABLE :table ADD PRIMARY KEY ("PLT_CN");

--ALTER TABLE :table ADD COLUMN oldgrowth boolean;
ALTER TABLE :table ALTER COLUMN oldgrowth TYPE boolean
USING
(
"STDAGE">80 
AND ("TRTCD1"='0' OR "TRTCD1" IS NULL)
AND (("DSTRBCD1"<>'30' AND "DSTRBCD1"<>'31' AND "DSTRBCD1"<>'32' AND "DSTRBCD1"<>'80') OR "DSTRBCD1" IS NULL)
AND ("STUMP_CD_PNWRS"='N' OR "STUMP_CD_PNWRS" IS NULL)
AND "HARVEST_TYPE1_SRS" IS NULL
AND "PRESNFCD" IS NULL
AND ("STDORGCD"=0 OR "STDORGCD" IS NULL)
)
OR "STND_COND_CD_PNWRS"='7'
;
