Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Using Count in SQL against a join...
All,
I've been away from SQL (and databases in general) since college, but I find myself struggling with what seems like a rather simple query -
It involves 2 tables --
Return Hit count on all Audited items for the users userA, UserB,
UserC. The Audit table contains the UserID, not the UserName, so I've
got this query returning the UserID working -
Select Audit.UserID, count(*)
from Audit
where Audit.UserID = 1575012 or Audit.UserID = 1575038 or Audit.UserID =
1575512
group by Audit.UserID
Now I want to change the UserID field in the output to the UserName field, but it's in a different table. So wouldn't I --
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. Any I deas? For a moment I thought that I needed to modify the count statement to show Audit.* or something...but that doesn't seem to work either.
Thanks. Received on Tue Oct 03 2000 - 14:46:24 CDT
![]() |
![]() |