I want to combine 4 tables with non-homogeneous fields and group by ID
and DESCRIPTION
and place all the uniform values in the same column as shown on the picture. I was able to query the union all but I can't move forward to grouping. How can I do this?
SELECT ID, USERNAME, LOGIN_ID, DESCRIPTION, RIGHT1, RIGHT2, RIGHT3, RIGHT4, '1A' ENTITY
FROM tbla
UNION ALL
SELECT ID, USERNAME, LOGIN_ID, DESCRIPTION, RIGHT1, '' RIGHT2, '' RIGHT3, '' RIGHT4, '1G' ENTITY
FROM tblb
UNION ALL
SELECT ID, USERNAME, LOGIN_ID, DESCRIPTION, RIGHT1, '' RIGHT2, '' RIGHT3, '' RIGHT4, '1S' ENTITY
FROM tblc
UNION ALL
SELECT ID, USERNAME, LOGIN_ID, DESCRIPTION, RIGHT1, '' RIGHT2, '' RIGHT3, '' RIGHT4, '1P' ENTITY
FROM tbld