Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query in a query - need help

Status
Not open for further replies.

klenot

Technical User
Aug 28, 2003
1
CZ
Hi SQL guruz,

I am just a beginner in the SQL and have a little problem.

I have an query which works flawlessly and return the expectant results. It looks like:

Code:
select idchain from chains
  group by 1
  having count (idchain) > 1

Now. I am not interested in the content of the result. I just want to know, how much rows this query will return. I tried to enclose all that query in the other, but it does not work. I get the syntax error instead of count of rows. This what I have tried:

Code:
select count (*) from (
    select idchain from chains
      group by 1
      having count (idchain) > 1
    )

What I am doing wrong?

Thanks in advance, Roman G., Prague
 
as JamesLean mentioned in another thread, I think the problem may be the need for an alias.

try
select count (*) from (
select idchain from chains
group by 1
having count (idchain) > 1
) subtbl

if this still doesn't work try

select count (*) from (
select idchain from chains
group by idchain
having count (idchain) > 1
) subtbl



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top