zoukankan      html  css  js  c++  java
  • 行字段值拼接成字符串

    效果:
    SizeBatchNoSizingDyeBatchs
    SZ1281656B2081036/B2081037/B2081042
     1 WITH    SizingJob ( SizeBatchNo, BatchNo )
     2           AS ( SELECT   b.SizeBatchNo ,
     3                         b.BatchNo
     4                FROM     WVMDB.dbo.wvSizingBatchInfo a WITH ( NOLOCK )
     5                         LEFT JOIN ydmdb.dbo.ydbeambatchno_sizing b WITH ( NOLOCK ) ON a.Sizing_Batch_NO = b.SizeBatchNo
     6                WHERE    a.End_Time IS NULL
     7              )
     8     SELECT  SizeBatchNo ,
     9             CASE WHEN LEN(SizingDyeBatchs) > 0
    10                  THEN STUFF(SizingDyeBatchs, LEN(SizingDyeBatchs), 1'')
    11                  ELSE ''
    12             END AS SizingDyeBatchs
    13     FROM    ( SELECT DISTINCT
    14                         SizeBatchNo
    15               FROM      SizingJob
    16             ) a
    17             CROSS APPLY ( SELECT    SizingDyeBatchs = ( SELECT
    18                                                               BatchNo + '/'
    19                                                         FROM  SizingJob
    20                                                         WHERE SizeBatchNo = A.SizeBatchNo
    21                           FOR       XML PATH('') ,
    22                                         TYPE
    23             ).value('/''nvarchar(max)')
    24


     1 WITH    SizingJob ( SizeBatchNo, BatchNo )
     2           AS ( SELECT   b.SizeBatchNo ,
     3                         b.BatchNo
     4                FROM     WVMDB.dbo.wvSizingBatchInfo a WITH ( NOLOCK )
     5                         LEFT JOIN ydmdb.dbo.ydbeambatchno_sizing b WITH ( NOLOCK ) ON a.Sizing_Batch_NO = b.SizeBatchNo
     6                WHERE    a.End_Time IS NULL
     7              )
     8     SELECT  SizeBatchNo ,
     9             CASE WHEN LEN(SizingDyeBatchs) > 0
    10                  THEN STUFF(SizingDyeBatchs, LEN(SizingDyeBatchs), 1'')
    11                  ELSE ''
    12             END AS SizingDyeBatchs
    13     FROM    ( SELECT DISTINCT
    14                         SizeBatchNo
    15               FROM      SizingJob
    16             ) a
    17             CROSS APPLY ( SELECT    SizingDyeBatchs = ( SELECT
    18                                                               BatchNo + '/'
    19                                                         FROM  SizingJob
    20                                                         WHERE SizeBatchNo = A.SizeBatchNo
    21                           FOR       XML PATH('') ,
    22                                         TYPE
    23             ).value('/''nvarchar(max)')
    24                         ) b

  • 相关阅读:
    C# WPF之Material Design自定义颜色
    C# WPF从RIOT API获取数据(RIOT代表作品《英雄联盟》)
    C# WPF聊天界面(3/3)
    C# WPF简况(2/3)
    C# WPF联系人列表(1/3)
    使用SignalR从服务端主动推送警报日志到各种终端(桌面、移动、网页)
    为什么Node.JS会受到青睐?
    2017级面向对象程序设计——团队作业1
    2017级面向对象程序设计 作业三
    如果抽不出时间写博客怎么办
  • 原文地址:https://www.cnblogs.com/yooplmqj/p/2696869.html
Copyright © 2011-2022 走看看