Joginder Banger

Joginder Banger

  • 214
  • 8.7k
  • 1m

case create a problem in sql server

Nov 20 2014 8:02 AM
hi every buddy,

plz solve my problem if any buddy understand. when i use case it throw error


set @sql ='select *
from
(
select  tsim.OrganisationCode orgcode , (case when tsim.OrganisationName is not null then '+'yes'+' else null end) as orgname,p.RouteofAdministration  from tbl_Product p
inner join tbl_ProductMaster as pm on p.fk_ProductMasterId=pm.ProductMasterId
inner join tbl_ProductSiteInpectedBy as ps on ps.fk_ProductMasterID=pm.ProductMasterId
inner join tbl_SiteInspectedBy_Master as tsim on tsim.OrganisationID=ps.fk_OrganisationID
) d
pivot
(
max(orgcode)  for orgname in ('+@columns+')
) as t2'


exec(@sql)


Answers (3)