Using the count aggregate in SQL (Informix)

Posted on 2012-09-21
Last Modified: 2012-09-21
I need to grab the id's out of a table where the count(id) is equal to 1.

In other words, I need to know the id's that only have one entry in this table...

I know this is simple but help me out...

select * from multi_race_rec where id in (select id  from multi_race_rec where count(id) = 1)

table schema:
race_no <--unique identifier
id <--- foreign key
race <--- two digit race code

I get a bad use of aggregate message when I try my idea on how to select them...
Question by:dcrowley_01
    LVL 8

    Accepted Solution

    try "select id from multi_race_rec group by id having count(id) = 1". I didn't test it with Informix but this is standard SQL so I'm assuming it should work.
    LVL 18

    Assisted Solution

    Even simpler would be this:

    select id,  
      from multi_race_rec            
     group by id
    having count(*) = 1

    Open in new window


    Author Closing Comment

    Thanks guys...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    761 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

    7 Experts available now in Live!

    Get 1:1 Help Now