• 行字段值拼接成字符串


    效果:
    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

  • 相关阅读:
    接口 多态
    继承extends (特点、重写、覆盖、应用)抽象abstract(定义、特点、细节)
    0515 面向对象 类与对象、局部、成员变量、基本、引用类型、封装 private 和this 及应用
    Eclipse 快捷键
    Flutter Framework启动代码阅读
    Flutter Widget概览
    Flutter局部状态管理
    iconfont应用
    implicit_animations.dart阅读
    Flutter异常搜集方案
  • 原文地址:https://www.cnblogs.com/yooplmqj/p/2696869.html
Copyright © 2020-2023  润新知