Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

select columns not in group by clause

935830May 8 2012 — edited May 8 2012
Hi 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 5 2012
Added on May 8 2012
4 comments
12,697 views