SQL CELL_NAME error message

Hello Community,

My colleague has compiled the following sql script in MS SQL 12

SELECT distinct fk_consumer_id
				   ,pk_country_id
				   ,CONTROL_GROUP_MEMBER
				   ,
					case 
                           when (CELL_NAME) LIKE '%RESC%'  then 'RESCUE' else 'Dunno' end as lifestage,

I tried to recreate the code in in my ms sql server but I get the error message 'Unknown identifier 'CELL_NAME'
Can you let me know where I'm getting the error message?

Thanks

no sample table and no sample data so it would just be guess work.
Works for me.

create table carltonp(fk_consumer_id int, pk_country_id int, 
CONTROL_GROUP_MEMBER varchar(50), CELL_NAME varchar(50))
insert into carltonp
select distinct object_id, column_id, name, bam  
From sys.columns 
cross apply (
select 'reschooling' as bam union 
select 'rescheduled' union
select 'reschedules' union
select 'rescissions' union
select 'rescindment' union
select 'rescreening' union
select 'resculpting' union
select 'rescription' 
) res


SELECT distinct fk_consumer_id
				   ,pk_country_id
				   ,CONTROL_GROUP_MEMBER
				   ,CELL_NAME
				   ,case 
                     when (CELL_NAME) LIKE '%RESC%'  
					 then 'RESCUE' else 'Dunno' 
					end as lifestage
from carltonp
drop table carltonp
1 Like

Perfect.

Thanks

Humm I did not do a thing but glad it worked out for you

yosiasz,

The output you provided lead me on the right path.

Thanks again