Intact Insurance Interview Question

data frame manipulations and sql query