Sunday, March 29, 2015

Replicated a particular string and create new column

Hi,


Are you sure that



MAT3774------- TRP005207420-- NON-FRU

NON-FRU ?


We have an Item



FRU300DRD----- TRP005207420-- FRU

With the same IdNum



Select * ,
isNull((
SELECT CAST(MAX(Case When Item like 'FRUA%' THEN 'FRUA'
When Item like 'FRUB%' THEN 'FRUB'
When Item like 'TX3%' THEN 'TX'
When Item like 'FRU%' THEN 'FRU'
ELSE null END) as Varchar(20)) AS GetType FROM #sample x WHERE x.IdNum = s.IDNum
GROUP BY IDNum
),'Non-FRU') as REMARKS
from #sample s






No comments:

Post a Comment