dbTalk Databases Forums  

sql query help

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss sql query help in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
hharry
 
Posts: n/a

Default sql query help - 04-26-2006 , 04:43 PM






hello all,

i have this table:

CREATE TABLE [dbo].[Table1] (
[person_id] [int] NULL ,
[dob] [varchar] (50) COLLATE SQL_Latin1_General_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


Reply With Quote
  #2  
Old   
Hugo Kornelis
 
Posts: n/a

Default Re: sql query help - 04-26-2006 , 04:50 PM






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

(snip)
Quote:
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
Hi hharry,

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


--
Hugo Kornelis, SQL Server MVP


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.