Basic SQL

  • Hi,

     

    I'm new to writing sql scripts and need a little help.  I have a table which contains client data.  Some clients have only 1 entry, some have multiples.  Table is keyed on clientID.  How do I get a list of the clients with multiple entries only ?

     

    Thanks,

    Jane

  • select clientID, count(*) from table

    group by clientID

    having count(*) > 1

  • As a general rule, table key should be unique. You may want to consider two tables instead of one. One for Client, the other for Client Data.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply