I have a situation where I have to use alais name for a field in the group by caluse. But Db2 is not allowing that. Can you please suggest this can be attained.
Below is the situation:
I have 2 tables tab1 and tab2. tab1 has fields A, B, C, D and tab2 has fields E, F, G,H. My query goes like this
SELECT count(*), COALESCE(tab2.G,tab1.C) as TID
LEFT JOIN tab2 ON
tab2.E=tab1.A and tab2.F=tab1.B
WHERE tab1.d > 20
GROUP BY TID