select * from (
SELECT "PROCE_UNIT_C" ,"EQUI_C" ,"COMPO_C" ,"COMPO_TYPE_C","CUIF_INS_CAT",
row_number() over(PARTITION BY "PROCE_UNIT_C", "EQUIP_C","COMPO_C","COMPO_TYPE_C","CUIF_INS_CAT") "Row_Number",
count("CUIF_INS_CAT") over(PARTITION BY "PROCE_UNIT_C", "EQUI_C","COMPO_C","COMPO_TYPE_C","CUIF_INS_CAT"),
CHR(min(ASCII("CUIF_INS_CAT")) over(PARTITION BY "PROCE_UNIT_C", "EQUI_C","COMPO_C","COMPO_TYPE_C"))
FROM
"INSPHISTORY" ) "a"
where "a"."Row_Number"=1
SELECT "PROCE_UNIT_C" ,"EQUI_C" ,"COMPO_C" ,"COMPO_TYPE_C","CUIF_INS_CAT",
row_number() over(PARTITION BY "PROCE_UNIT_C", "EQUIP_C","COMPO_C","COMPO_TYPE_C","CUIF_INS_CAT") "Row_Number",
count("CUIF_INS_CAT") over(PARTITION BY "PROCE_UNIT_C", "EQUI_C","COMPO_C","COMPO_TYPE_C","CUIF_INS_CAT"),
CHR(min(ASCII("CUIF_INS_CAT")) over(PARTITION BY "PROCE_UNIT_C", "EQUI_C","COMPO_C","COMPO_TYPE_C"))
FROM
"INSPHISTORY" ) "a"
where "a"."Row_Number"=1