You are here: complex merging query in sql server 2000 « MsSQL Server « IT news, forums, messages
complex merging query in sql server 2000

Posted by mrclash on 10/06/06 12:26

Hello,

I have a Database in a SQL Server 2000 where I have different users
tables with equal fields like this:

id (int)
email (varchar)
name (varchar)
address (varchar)
joinedon (datetime)

I want to merge all the tables in one taking rows with the same email
but taking always the more recent fields based on the 'joinedon' field.
So if I have this four different rows:

Tbl email name address joinedon
--------------------------------------------------------------------------------------------
T1 j@smith.com johnathan NULL 01/01/95
T2 j@smith.com NULL barcelona street 01/01/98
T3 j@smith.com john valencia street 01/01/97
T4 j@smith.com john Q NULL 01/01/99

And the final row entered in the new table would be

Tbl email name address joinedon
----------------------------------------------------------------------------------------
new j@smith.com john Q barcelona street 01/01/99

I am trying doing his with union statements, but i am not getting the
real merging of data. Any clue?

Thanks for your help.

 

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

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