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)
 Pulling same field from a table many times

Author  Topic 

nlocklin
Yak Posting Veteran

69 Posts

Posted - 2001-09-26 : 16:38:55
Ok, it's near the end of the day here and so maybe I'm just missing the obvious, but here's what I'm having a hard time writing a SQL statement for:

I have one table with people's personal information, and another table with a series of forms for each person. There will be up to eight forms in the form table for each person, numbered 1-8 in the FormNumber field:

tblPerson
PersonID - primary key
FirstName
LastName
etc

tblForms
FormID - primary key
PersonID - foreign key
FormDate
FormNumber
etc

What I'm trying to do is write a select statement that will return the person's ID number, along with the FormDate (labelled FormDate1, FormDate2, FormDate3, etc) for each of the eight possible forms received. If there is no entry for that particular form number, the FormDate value for that particular form should just be NULL. Any help or advice would be very much appreciated.


--
"It's not that I'm lazy, it's that I just don't care."
   

- Advertisement -