zoukankan      html  css  js  c++  java
  • group by 一条语句实现多条语句的效果

        --一个sql 使用 group by 实现 4个 sql 的效果
            select ProjectNumber,ClientName,jx,sf,sum(count) as TotalCount from tlog 
            where StDate>='2017-10-01' and StDate<'2017-11-01' 
            group by ProjectNumber,ClientName,jx,sf
            
            -- jx=1 and sf=1 
            select ClientName,sum(Count) as 'TotalCount' from tlog where 
            jx=1 and sf=1 
            and (StDate>='2017-10-01' and StDate<'2017-11-01') 
             group by ClientName
            -- jx=1 and sf=0 
             select ClientName,sum(Count) as 'TotalCount' from tlog where 
            jx=1 and sf=0 
            and (StDate>='2017-10-01' and StDate<'2017-11-01') 
             group by ClientName
           --  jx=0 and sf=1 
             select ClientName,sum(Count) as 'TotalCount' from tlog where 
            jx=0 and sf=1 
            and (StDate>='2017-10-01' and StDate<'2017-11-01') 
             group by ClientName
            -- jx=0 and sf=0 
             select ClientName,sum(Count) as 'TotalCount' from tlog where 
            jx=0 and sf=0 
            and (StDate>='2017-10-01' and StDate<'2017-11-01') 
             group by ClientName
  • 相关阅读:
    http
    node 学习 http
    socket.io
    每日日报
    每日日报
    每日日报
    06人件读书笔记之一
    每日日报
    每日日报
    05程序员修炼之道:从小工到专家阅读笔记之三
  • 原文地址:https://www.cnblogs.com/25miao/p/7892139.html
Copyright © 2011-2022 走看看