Evening all,
I've been trying to get this to work for the last few hours with little success. I'm trying to get some data out of an old database. Basically I have a table that has a ClientID and address details and another table with ClientID and contact details. Unfortunately the contact details have a key column not separate columns for each type of contact... OK So the query I have at the moment is:
Select
Name, Notes,
KnownAs, AddressLine1, AddressLine2, Town, City, County, PostCode,
Salutation, FirstName, LastName, Position,
(Select ContactNumber Where ContactNumberTypeID = 'SYSEMAIL') As Email,
(Select ContactNumber Where ContactNumberTypeID = 'SYSFAX') As Fax,
(Select ContactNumber Where ContactNumberTypeID = 'SYSTEL') As Tel,
(Select ContactNumber Where ContactNumberTypeID = 'SYSMOBILE') As Mob,
(Select ContactNumber Where ContactNumberTypeID = 'SYSUNKNOWN') As Unknown
From [dbo].[ptdClient]
Inner Join [dbo].[ptdClientContactNumber]
On ptdClient.ClientID = ptdClientContactNumber.ClientID
Where Name = 'My_Test_Record'
Essentially the works fine, but it outputs 4 lines (1 for each ContactNumberTypeID). I only want 1 line out put but with the 4 ContactNumberTypeID's in separate columns. I've tried grouping but I can't get it to work... Can anyone offer any pointers please...
Thanks
Dave
PS Hope it makes sense...