I want to dynamically add another column hook_name, via an SQL select query, based on a condition.
hook_name
For example if hook_type = 0, table ho
hook_type = 0
ho
Use a Standard SQL CASE:
SELECT hook_type, CASE hook_type WHEN 0 THEN 'OFFER' WHEN 1 THEN 'ACCEPT' WHEN 2 THEN 'EXPIRED' END AS hook_name, COUNT(*) AS number_of_exchange_activities FROM `exchange` GROUP BY hook_type