SELECT ACT,
CASE
WHEN
MIN(CASE WHEN ACTIND = '01' THEN 1 END) +
MIN(CASE WHEN ACTIND = '02' THEN 1 END) +
MIN(CASE WHEN ACTIND = '07' THEN 1 END) IS NOT NULL
THEN '02'
WHEN
MIN(CASE WHEN ACTIND = '01' THEN 1 END) +
MIN(CASE WHEN ACTIND = '02' THEN 1 END) IS NOT NULL
THEN '02'
WHEN
MIN(CASE WHEN ACTIND = '01' THEN 1 END) +
MIN(CASE WHEN ACTIND = '07' THEN 1 END) IS NOT NULL
THEN '07'
WHEN
MIN(CASE WHEN ACTIND = '02' THEN 1 END) +
MIN(CASE WHEN ACTIND = '07' THEN 1 END) IS NOT NULL
THEN '02'
ELSE MAX(ACTIND)
END
FROM ...
GROUP BY 1

Or a simplified CASE

CASE
WHEN
MIN(CASE WHEN ACTIND IN ('01','07') THEN 1 END) +
MIN(CASE WHEN ACTIND = '02' THEN 1 END) IS NOT NULL
THEN '02'
WHEN
MIN(CASE WHEN ACTIND = '01' THEN 1 END) +
MIN(CASE WHEN ACTIND = '07' THEN 1 END) IS NOT NULL
THEN '07'
ELSE MAX(ACTIND)
END

Hi , I tried checking forums before posting this query. Please suggest

I am getting below o/p by joining couple of tables

ACT ACTINDA1 01

A1 02

A1 02

A1 03

A2 01

A2 03

A2 03

A3 01

A3 01

A3 01

Actually I wanted below o/p by using above result.

ACT ACTIND

A1 02

A2 03

A3 01

( If a act has more than one combination of Indicator select only one from them using some rules

For ex : if a particualr act has 01,02,03 then only select 02

if a act has 01 , 03 then select only 03