In this table, if Clm and cos have the same numbers and Title = T16 and the other is T2 I want their titles to be called Concurr (this table is what I want the stored procedure to create)
Doc Clm Cos FileDate Rcpt Title
S66 454442 454442 06/03/2010 06/11/2010 Concurr
S66 454442 454442 06/04/2010 06/13/2010 Concurr
S09 456842 455987 07/03/2010 08/03/2010 T16
S66 157962 157962 08/03/2010 08/03/2010 T2
S66 182659 182659 05/04/2010 05/17/2010 Concurr
S66 182659 182659 05/07/2010 05/17/2010 Concurr
This is the table I'm working with called Test. Below I have the create table and insert statements.
Doc Clm Cos FileDate Rcpt Title
S66 454442 454442 06/03/2010 06/11/2010 T16
S66 454442 454442 06/04/2010 06/13/2010 T2
S09 456842 455987 07/03/2010 08/03/2010 T16
S66 157962 157962 08/03/2010 08/03/2010 T2
S66 182659 182659 05/04/2010 05/17/2010 T16
S66 182659 182659 05/07/2010 05/17/2010 T2
CREATE TABLE [dbo].[test](
[doc] [varchar](3) NOT NULL,
[clm] [char](6) NOT NULL,
[cos] [char](6) NOT NULL,
[FileDate] [char](30) NULL,
[DDSRcpt] [char](30) NULL,
[Title] [varchar](3) NOT NULL
) ON [PRIMARY]
insert into test
select 'S66', '454442', '454442', '06/03/2010', '06/11/2010', 'T16' union all
select 'S66', '454442', '454442', '06/04/2010', '06/13/2010', 'T2' union all
select 'S09', '456842', '456842', '07/03/2010', '08/03/2010', 'T16' union all
select 'S66', '157962', '157962', '08/03/2010', '08/03/2010', 'T2' union all
select 'S66', '182659', '182659', '05/04/2010', '05/17/2010', 'T16' union all
select 'S66', '182659', '182659', '05/07/2010', '05/17/2010', 'T2'
I tried this but the results didn't come out right:
SELECT clm, [cos], Title =
case
when clm = [cos] then
'concurr'
End
FROM test
Doc Clm Cos FileDate Rcpt Title
S66 454442 454442 06/03/2010 06/11/2010 Concurr
S66 454442 454442 06/04/2010 06/13/2010 Concurr
S09 456842 455987 07/03/2010 08/03/2010 T16
S66 157962 157962 08/03/2010 08/03/2010 T2
S66 182659 182659 05/04/2010 05/17/2010 Concurr
S66 182659 182659 05/07/2010 05/17/2010 Concurr
This is the table I'm working with called Test. Below I have the create table and insert statements.
Doc Clm Cos FileDate Rcpt Title
S66 454442 454442 06/03/2010 06/11/2010 T16
S66 454442 454442 06/04/2010 06/13/2010 T2
S09 456842 455987 07/03/2010 08/03/2010 T16
S66 157962 157962 08/03/2010 08/03/2010 T2
S66 182659 182659 05/04/2010 05/17/2010 T16
S66 182659 182659 05/07/2010 05/17/2010 T2
CREATE TABLE [dbo].[test](
[doc] [varchar](3) NOT NULL,
[clm] [char](6) NOT NULL,
[cos] [char](6) NOT NULL,
[FileDate] [char](30) NULL,
[DDSRcpt] [char](30) NULL,
[Title] [varchar](3) NOT NULL
) ON [PRIMARY]
insert into test
select 'S66', '454442', '454442', '06/03/2010', '06/11/2010', 'T16' union all
select 'S66', '454442', '454442', '06/04/2010', '06/13/2010', 'T2' union all
select 'S09', '456842', '456842', '07/03/2010', '08/03/2010', 'T16' union all
select 'S66', '157962', '157962', '08/03/2010', '08/03/2010', 'T2' union all
select 'S66', '182659', '182659', '05/04/2010', '05/17/2010', 'T16' union all
select 'S66', '182659', '182659', '05/07/2010', '05/17/2010', 'T2'
I tried this but the results didn't come out right:
SELECT clm, [cos], Title =
case
when clm = [cos] then
'concurr'
End
FROM test