Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Using Count in SQL against a join...
Sean Alderman schrieb:
[..]
> Select UserInfo.UserName, count(Audit.*)
> From UserInfo, Audit
> Where Audit.UserID = 1575012 or Audit.UserID = 1575038 or Audit.UserID
> = 1575512
> And UserInfo.UserID = Audit.UserID
> Group by UserInfo.UserID
>
> It tells me I'm tring to acces an invalid column.
[..]
You got ORA-01747: invalid user.table.column, table.column, or column
specification
due to the count(Audit.*)
If you change that to count(*) you will get ORA-00979: not a GROUP BY expression, cause you have group by UserInfo.UserId but selected UserInfo.UserName.
Please change that to group by UserInfo.UserName:
Select UserInfo.UserName, count(*)
From UserInfo, Audit
Where ( Audit.UserID = 1575012 or Audit.UserID = 1575038 or
Audit.UserID= 1575512 )
And UserInfo.UserID = Audit.UserID
Group by UserInfo.UserName
So, this should work. BTW I've added some brackets to avoid cartesian join, OK?
![]() |
![]() |