You are here: Re: a small SQL Puzzle « MsSQL Server « IT news, forums, messages
Re: a small SQL Puzzle

Posted by Roy Harvey (SQL Server MVP) on 09/26/07 18:47

Unless there are twins who are both the oldest this will do what you
ask.

SELECT *
FROM SomeTable as A
WHERE birthdate =
(SELECT MIN(birthdate)
FROM SomeTable as B
WHERE A.address = B.address)

Roy Harvey
Beacon Falls, CT

On Wed, 26 Sep 2007 20:37:12 +0200, Fiori <dab@xs4all.nl> wrote:

>Hi,
>
>Probable there is a simple solution for this, hopefully someone can
>direct me in the right direction.
>
>I have a table with a persons firstname, lastname, birthdate and
>address. However, I want to select only one person per address, namely
>the eldest of all persons living on the same address.
>
>Can anyone provide me a solution?
>
>Thanks in advance.
>Duncan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация