IBM Interview Question

1 SQL, 1 Categorical variable question - you should be good with break down the logic and implementing it via any programming language in the given time.