select columns not in group by clause
935830May 8 2012 — edited May 8 2012Hi Guys,
I want to fetch columns from a table which are not in group by clause. The catch here is that I also need a count and decode column..
SELECT col_A, col_B, decode(col_C, '10', '10', '26', '26', '00') col_CT, col_X, col_Y count(*) CNT
FROM TABLE_T
WHERE col_B IN (100,101,102) AND col_C IN ('44','45','10','26')
GROUP BY col_A, col_B, decode(col_C, '10', '10', '26', '26', '00')
ORDER BY col_CT
Since, col_X and col_Y are not in GROUP BY clause, it throws error. Also, decode/count of the columns makes it more complex.
Please help me on this.
Thanks,
Amy