/* Formatted on 19/7/2022 23:38:14 (QP5 v5.396) */
SELECT user_group, cust_id, cust_no
FROM employees
UNPIVOT (cust_id
FOR cust_no
IN (eid1 AS 1,
eid2 AS 2,
eid3 AS 3))
classic¶
select user_group, 1, eid1 from employees where cust_id1 is not null union all
select user_group, 2, eid2 from employees where cust_id2 is not null union all
select user_group, 3, eid3 from employees where cust_id3 is not null