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 -> Re: Using Count in SQL against a join...

Re: Using Count in SQL against a join...

From: Sigmar Wiesmayr <wis_at_ecolog.at>
Date: Tue, 10 Oct 2000 01:13:04 +0200
Message-ID: <39E25100.6FF13F17@ecolog.at>

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?

Received on Mon Oct 09 2000 - 18:13:04 CDT

Original text of this message

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