Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Using Count in SQL against a join...

Using Count in SQL against a join...

From: Sean Alderman <sean.m.alderman_at_grc.nasa.gov>
Date: Tue, 03 Oct 2000 15:46:59 -0400
Message-ID: <39DA37B2.BF6D342C@grc.nasa.gov>

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:59 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US