Hi, below is my sample data and I need to write a case statment with the below condtions -
1) if a custid has just ONE distinct pgroupcode as 101 and matching cgroupcode as 101 and flag as Y then my CASEs should return 1. PLease note that 101 can be hardcoded for this case statement.
2) however, if a custid has more than one pgroupcode with matching cgroupcode and flag as as Y for ALL the
pgroupcode and cgroupcodes then the CAse SHOULD return 1.
all other scenarios case should return 0
Can anyone please give me that CASE statement ?
for the below data, for custid 6671 case should return 0 as it has got 2 different pgroupcodes and one of them with matching cggroupcode has FLAG N. So case should return 0
for custids 5500 and 6400, case should return 1 as it has got only 1 PGgroupcode with matching cggroupcode with FLAG Y.
Custid pgroupcode cgroupcode Catcode Flag
6671 101 101 BCG Y
6671 101 101 BCG N
6671 101 985 BCG N
6671 115 115 BCG N
5500 101 101 BCG Y
6400 101 101 BCG Y