dynamically build a CASE statement(never used)