hi everyone, for all of you plsql gurus I have a question:
SELECT a.id,
a.name,
b.name,
....
(CASE WHEN sub_c.value_c = '2015' AND a.code >= 1111 THEN 'Output value is ' || a.value_a ELSE 'Random value' END) output
FROM table_a a,
table_b b,
...
(SELECT c.a_id
MAX(CASE WHEN c.code <> 'A'
THEN c.value
END) value_c
FROM table_c
GROUP BY c.a_id
) sub_c
WHERE a.id = b.a_id
AND a.id = sub_c.a_id ( + )
So they want all a_id from table_c, and if WHEN condition is not satisfied they still want that a_id even with NULL for value_c.
I've tried to outline the most important parts, so the question is: is there a way to avoid using this MAX-CASE construct to speed this query up a little?
Thanks a ton to anyone who bothered to look at this!