select distinct tp.[order],tp.Module,
(case tpt.Name when 'Color' then Value else '' end) Color,
(case tpt.Name when 'Total' then Value else '' end) Total,
(case tpt.Name when 'DeliveryDate' then Value else '' end) DeliveryDate 
from UserDataModel.T_LeanLinePlan tp left join
UserDataModel.T_LeanLinePlanAttribute tpt
on tp.LeanLinePlanId=tpt.LeanLinePlanIdvalue值为‘’,所有数据集出现很多空白的

解决方案 »

  1.   

    其实不是很懂你的问题,不过你可以加上isnull(xx,'')试试。
      

  2.   

    行转列,    value的值 是  Nvarchar类型。如果合并
      

  3.   


    select tp.[order],tp.Module,
    Max(case tpt.Name when 'Color' then Value else '' end) Color,
    Max(case tpt.Name when 'Total' then Value else '' end) Total,
    Max(case tpt.Name when 'DeliveryDate' then Value else '' end) DeliveryDate 
    from UserDataModel.T_LeanLinePlan tp left join
    UserDataModel.T_LeanLinePlanAttribute tpt
    on tp.LeanLinePlanId=tpt.LeanLinePlanId
    Where Name in('Color','Total','DeliveryDate')
    Group by tp.[order],tp.Module