or select A, CASE WHEN B IN(1,2) THEN 'Type A' ELSE 'Type B' END AS B, C from table_a groupby A, CASE WHEN B IN(1,2) THEN 'Type A' ELSE 'Type B' END, C
using a column alias defined in the select clause, is not valid in the group by. On 4 December 2011 09:21, Mapred Learn <mapred.le...@gmail.com> wrote: > Hi, > I have a following smaple query: > > select > A, > CASE > WHEN B IN(1,2) THEN 'Type A' > ELSE 'Type B' > END AS B, > C > from table_a > groupby > A, B, C; > > But when i run this query, it gives error: > FAILED: Error in semantic analysis: Line 95:0 Invalid table alias or > column reference entity > > This error is from B defined after 'AS' in CASE statement. > > how can I make this group-by work ? > > Thanks, > -JJ > > >