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!

Count(*) with nested query

811642Mar 1 2011 — edited Mar 1 2011
Hi,
I have a question about the count(*) with nested query.

I have a table T1 with these columns:
C1 number
C2 number
C3 number
C4 number
C5 number

(The type of each column is not relevant for the example.)

This query:
select C1, C2, C3, C4
from T1
group by C1, C2

it's not correct becausa C3 and C4 are not columns specified in the GROUP BY expression.

If if run this query:
select count(*)
from (select C1, C2, C3, C4
from T1
group by C1, C2)

I haven't an error message (the result is correctly the number of records).

Why?

Thanks.

Best regards,
Luca
This post has been answered by Ganesh Srivatsav on Mar 1 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 29 2011
Added on Mar 1 2011
3 comments
868 views