Solved

Syntax problem Informix with COUNT and HAVING

Posted on 1998-10-29
1
784 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating and Managing Databases with phpMyAdmin in cPanel.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
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…

751 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