SELECT DAT.*FROM customer DAT WHERE DATEDIFF(mod,trans)>=CASE WHEN type IN('Sal', 'Adv') THEN 365 WHEN type IN('Cus') THEN 14 ELSE NULL END;