sql query help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hharry

    sql query help

    hello all,

    i have this table:

    CREATE TABLE [dbo].[Table1] (
    [person_id] [int] NULL ,
    [dob] [varchar] (50) COLLATE SQL_Latin1_Gene ral_CP1_CI_AS NULL
    ) ON [PRIMARY]
    GO

    with these values:

    insert into Table1 values ('1', '15/12/1975')
    insert into Table1 values ('1', '01/01/1980')
    insert into Table1 values ('2', '15/12/1975')
    insert into Table1 values ('1', '15/12/1975')

    i am trying to construct a query which will return those person's with
    more than 1 date of birth
    e.g.
    person 1 has 2 dates of birth - 01/01/1980 and 15/12/1975

    thanks in advance

  • Hugo Kornelis

    #2
    Re: sql query help

    On 26 Apr 2006 14:43:02 -0700, hharry wrote:

    (snip)[color=blue]
    >i am trying to construct a query which will return those person's with
    >more than 1 date of birth
    >e.g.
    >person 1 has 2 dates of birth - 01/01/1980 and 15/12/1975[/color]

    Hi hharry,

    SELECT person_id, COUNT(*)
    FROM Table1
    GROUP BY person_id
    HAVING COUNT(*) > 1


    --
    Hugo Kornelis, SQL Server MVP

    Comment

    Working...