http://topic.csdn.net/u/20080614/17/22e73f33-f071-46dc-b9bf-321204b1656f.html

解决方案 »

  1.   

    select OrderNO,
      max(case secq when 1 then Picture else '' end) Picture1,
      max(case secq when 2 then Picture else '' end) Picture2,
      max(case secq when 3 then Picture else '' end) Picture3
    from tb
    group by orderno
      

  2.   

    谢谢大家的回答,可picutre是image类型,不能用sum或max函数
    还请赐教
      

  3.   

    picure字段是image格式,不能使用sum或max函数来操作,还请赐教
      

  4.   

    --试试把我给的例的中picture全部改为cast(Picture as varchar)
    select OrderNO,
     max(case secq when 1 then cast(Picture as varchar) else '' end) Picture1,
     max(case secq when 2 then cast(Picture as varchar) else '' end) Picture2,
     max(case secq when 3 then cast(Picture as varchar) else '' end) Picture3
    from tb
    group by orderno
      

  5.   


    不可以,出现错误提示:消息 529,级别 16,状态 2,第 2 行
    不允许从数据类型 image 到 varchar 的显式转换
      

  6.   

    楼主我只想对你说这么几句:
    picture 里存放的是 image(二进制数据)那么你对此做行转列的意义何在? 报表里输出一大串二进制数?如果确实要这样的结构:只需订单号        图片1        图片2          图片3
    A0001        此单号下唯一可定位到图片1的标识 此单号下唯一可定位到图片2的标识   此单号下唯一可定位到图片3的标识假设你的secq在每组订单号中是唯一的,那么你只需要
    订单号        图片1        图片2          图片3
    A0001         1             2             3
    这样的结果就是了。显示图片时,可以通过单号及secq唯一定位取到image数据再显示出来。
    你非要行转列显示二进制数据,是没有意义的。如果没想明白,建议多想想, 不是能不能做到,而是应该不。