none
sql server 中行合并问题 RRS feed

  • 问题

  • sql 代码如下:

    ;WITH o AS 
    (SELECT f.*,
                s.Mt,
                d.Stad,
                l.Qbad,
                g.Mad,
                g.Aad,
                g.Vad
      FROM      dbo.v_basicInfo f
      LEFT JOIN dbo.qd_qs s
        ON s.SampleNo   = f.SampleNo
       AND s.SampleType = f.SampleType
       AND s.Version    = f.Version
      AND s.TestTime = f.QsTestTime
      LEFT JOIN dbo.qd_gfy g
        ON g.SampleNo   = f.SampleNo
       AND g.SampleType = f.SampleType
       AND g.Version    = f.Version
       AND g.TestTime = f.GfyTestTime
      LEFT JOIN dbo.qd_dly d
        ON d.SampleNo   = f.SampleNo
       AND d.SampleType = f.SampleType
       AND d.Version    = f.Version
       AND d.TestTime = f.DlyTestTime
       
      LEFT JOIN dbo.qd_lry l
        ON l.SampleNo   = f.SampleNo
       AND l.SampleType = f.SampleType
       AND l.Version    = f.Version
       AND l.Testtime = f.LryTestTime
       WHERE f.SampleType IN (1,3) AND f.SampleNo='2020111414A' 
       )
    
    SELECT *
    FROM o

    显示如上。 我想要进行 行合并 ,合并的最终结果为 2 行。

    2020年11月15日 2:18