Union all not returning data
Or, you could simply use:
SELECT
col1,
col2,
col3,
CASE WHEN col4 = 'A' THEN col4
WHEN col5 = 'B' THEN col5
END as type
FROM table1
WHERE col4 = 'A' OR col5 = 'B'
This will only show each row once, whereas your query might have shown the same row multiple times if col4 = 'A' AND col5 = 'B'
.