zoukankan      html  css  js  c++  java
  • 列和相减 L3L2

    --列和相减 L3-L2
    declare @test table(L1 varchar(50),L2 int,L3 int)
    insert into @test
    select 'A1',10,10 union all
    select 'A1',10,5 union all
    select 'A1',5,5 union all
    select 'B1',10,20 union all
    select 'B1',5,5

    select * from @test
    select a.*,b.L4 from @test a join
    (
    select L1,sum(L3)-Sum(L2) as L4 from @test group by L1) b on a.L1=b.L1


    /*
    L1                                                 L2          L3
    -------------------------------------------------- ----------- -----------
    A1                                                 10          10
    A1                                                 10          5
    A1                                                 5           5
    B1                                                 10          20
    B1                                                 5           5



    L1                                                 L2          L3          L4
    -------------------------------------------------- ----------- ----------- -----------
    A1                                                 10          10          -5
    A1                                                 10          5           -5
    A1                                                 5           5           -5
    B1                                                 10          20          10
    B1                                                 5           5           10

    (5 行受影响)
    */
  • 相关阅读:
    CF185D Visit of the Great 解题报告
    CF1468M Similar Sets 解题报告
    CFgym102439 做题记录
    CF1187F Expected Square Beauty 解题报告
    CFgym103202 做题记录
    搜索学习笔记
    小甲鱼Python第019讲函数:灵活即强大 | 课后测试题及参考答案
    小甲鱼Python第018讲函数:灵活即强大 | 课后测试题及参考答案
    小甲鱼Python第017讲函数
    小甲鱼Python第016讲序列!序列!| 课后测试题及参考答案
  • 原文地址:https://www.cnblogs.com/zengxiangzhan/p/1638153.html
Copyright © 2011-2022 走看看