Solved

Syntax problem Informix with COUNT and HAVING

Posted on 1998-10-29
1
733 Views
Last Modified: 2012-08-13
Hi,

I try to do the following query (which I thought is plain SQL), but it results in an error:

SELECT person_id
FROM job_function
GROUP BY person_id
HAVING COUNT(person_id) > 1

(IN NL: Give me all person_id's of those rows in the table that have this person_id more than once, which means, "Give me all persons with more than one function").

The database complains that the syntax is not OK. It isn't usefull, but when I put a distinct inside the COUNT, the answer of course is wrong, but the syntax seems right.... It seems the problem is a COUNT(field) is not supported, whereas a COUNT(*) is supported.

The database used is a very stripped Informix that was delivered with the Netscape Enterprise 2.0 webserver, with LiveWire Pro....

I think it's just a difference in syntax....

Cheers,


    George
0
Comment
Question by:georgedb
1 Comment
 
LVL 1

Accepted Solution

by:
csalves earned 20 total points
ID: 1025883
Hello,

This another way to do it.

SELECT a.person_id
  FROM job_function a
  WHERE a.rowid <> ANY (SELECT b.rowid
                          FROM job_function b
                          WHERE a.ROWID <> b.ROWID
                            AND a.person_id = b.Person_id)
GROUP BY a.person_id

This statement will return all the persons with more than one job function.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now