Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Converting rows into collums

Author  Topic 

naoh
Starting Member

1 Post

Posted - 2011-02-17 : 06:50:05
hi there,

I´m a newbie in SQL so i´ve a newbie question .
Í have a table that has contracts of employes:

Nprocesso StartDate EndDate
485 01-01-2000 01-01-2001
485 02-01-2001 01-01-2002
485 02-01-2002 01-01-2003
501 08-05-2004 07-05-2005
501 08-05-2006 07-05-2007
....

where "nprocesso" is the number thar identifies the employe

I´ve a second table that has the basic information of each one:
nprocesso (primary Key) ,name, gender, adress,....

I want to join both tables into a only row so that the contract information stays in the same row.

Ex:
Name Gender Adress StartDate1 EndDate1 StartDate2 EndDate2

the max needed StarDate and EndDate are 5 collums (therefore the max rows of each employe in the cotract table is 5)

I can join both table with a simple left join on nprocesso but it duplicates row´s number.

Can you help me?
   

- Advertisement -