You are here: Re: MS SQL dealing with duplicate columns in rows? « MsSQL Server « IT news, forums, messages
Re: MS SQL dealing with duplicate columns in rows?

Posted by David Portas on 08/21/07 18:40

"Yas" <yasar1@gmail.com> wrote in message
news:1187701509.682453.306820@o80g2000hse.googlegroups.com...
> On 21 Aug, 11:20, stephen <m0604...@googlemail.com> wrote:
>> On Aug 21, 10:04 am, Yas <yas...@gmail.com> wrote:
>>
>>
>>
>> > Hello,
>>
>> > Suppose I have the following table...
>>
>> > name employeeId email
>> > --------------------------------------------
>> > Tom 12345 t...@localhost.com
>> > Hary 54321
>> > Hary 54321 h...@localhost.com
>>
>> > I only want unique employeeIds return. If I use Distinct it will still
>> > return all of the above as the email is different/missing. Is there a
>> > way to query in SQL so that only distinct employeeId is returned? no
>> > duplicates.
>>
>> > I wouuld like to say WHERE no blank fields are present to get the
>> > right row to return.
>>
>> > Many thanks
>>
>> > Yas
>>
>> Which row for Hary do you want to be returned? The one without an
>> email address or the one with the email address?
>
> basically 1 that doesn't have any fields missing....
>
> cheers
>

What is the key of your table? If you don't have a key then you need to fix
the design before you can expect a reasonable solution in SQL.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

 

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

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