dbTalk Databases Forums  

Simple (hopefully) query question

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Simple (hopefully) query question in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #21  
Old   
shakespeare
 
Posts: n/a

Default Re: Simple (hopefully) query question - 02-08-2008 , 11:35 AM







<fitzjarrell (AT) cox (DOT) net> schreef in bericht
news:1760fa08-6a51-467a-92a4-22c0781cc513 (AT) s37g2000prg (DOT) googlegroups.com...
On Feb 7, 3:14 pm, "shakespeare" <what... (AT) xs4all (DOT) nl> wrote:
Quote:
fitzjarr... (AT) cox (DOT) net> schreef in
berichtnews:46eaf728-d37c-4b8c-934f-662495d16fed (AT) e23g2000prf (DOT) googlegroups.com...
On Feb 6, 2:22 pm, TonyV <kingskip... (AT) gmail (DOT) com> wrote:





Hey all, I'm having a problem with what should be a simple query. I
don't know if my brain is fried today or what, but hopefully the
following simple example will explain what I'm trying to do:

-- Does NOT work
select col_name, col_count
from (
select column1 "col_name", count(column1) "col_count"
from table_name
group by column1
)
where col_count > 1;

When I try to run this, I get dinged with a 904 error, invalid
identifier.

My question is this: How can I select the name and count of something
where the count is greater than one?

Use group by and having:

select column1 "col_name", count(column1) "col_count"
from table_name
group by column1
having count(column1) > 1;

David Fitzjarrell

-----------------------------------
Works too, even better.....
The cause of the error however were the quotes....

Shakespeare- Hide quoted text -

- Show quoted text -
I understand that, but the question, clearly presented at the end of
the post:

"My question is this: How can I select the name and count of something
where the count is greater than one?"

Which I answered.


David Fitzjarrell

----------------------------------------

David,

you're right... ;-)

Shakespeare




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.