I need to find the multiple relationship with a Customer in one row. It would be able to search based on given criteria. and return results like :
Customer: Relations
AA1: Friend, Relative
AA2: Friend, Coleague
AA3: Student
here is the provided data code:
CREATE TABLE [dbo].[Customers](
[Id] [int] IDENTITY(1,1) NOT NULL,
[CustomerName] [varchar](50) NOT NULL,
[Status] [varchar](50) NULL,
[AddedDatetime] [datetime] NULL,
CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Customers] ADD CONSTRAINT [DF_Customers_AddedDatetime] DEFAULT (getdate()) FOR [AddedDatetime]
GO
insert into dbo.Customers (CustomerName, [Status]) values ('AA1', 'Friend')
insert into dbo.Customers (CustomerName, [Status]) values ('AA2', 'Friend')
insert into dbo.Customers (CustomerName, [Status]) values ('AA1', 'Relative')
insert into dbo.Customers (CustomerName, [Status]) values ('AA2', 'Coleague')
insert into dbo.Customers (CustomerName, [Status]) values ('AA3', 'Student')
select * from Customers
please help.
Shamshad Ali