zoukankan      html  css  js  c++  java
  • Sale表中横列值转换成竖列显示。

    SELECT EmployeeID,
        
    max(case SaleDate when '2007-01-01' then amount else null endas jan,
        
    max(case SaleDate when '2007-02-01' then amount else null endas feb,
        
    max(case SaleDate when '2007-03-01' then amount else null endas mar,
        
    max(case SaleDate when '2007-04-01' then amount else null endas apr,
        
    max(case SaleDate when '2007-05-01' then amount else null endas may,
        
    max(case SaleDate when '2007-06-01' then amount else null endas jun,
        
    max(case SaleDate when '2007-07-01' then amount else null endas aug
    from Liaohaibing.SALE
    group by Liaohaibing.SALE.EMPLOYEEID;

    EmployeID  jan  feb  mar  apr  may  jun  aug
     1 1005 1452 524 345 567 587 524
    2 1008 5224 524 345 567 578 552
    3 1007 5424 524 345 567 698 5224
    4 1005 5524 524 345 567 895 54
    5 1009 5224 524 345 567 698 554
    6 1008 524 524 345 567 2452 5221
    7 1006 524 524 345 567 354 4
    8 1005 524 524 345 567 243 5
    9 1005 524 524 345 567 2546 556
    10 100 524 524 345 567 5244 254

    有一个 Sale  表里面放着每个销售员每个月的销售情况

    现在要把这一年,按月分进行显示出每个销售员得销售情况。

    上面这种法子可以实现。

  • 相关阅读:
    无参装饰器
    针对硬盘大于2TB,centos7系统安装问题说明
    Java与Python擅长领域
    Java数据类型
    编译型语言与解释型语言,强类型语言与弱类型语言,动态类型语言与静态类型语言
    Butterfly透明背景设置
    虚拟机重装系统
    手动删除软件垃圾
    清理C盘
    Gitee+HEXO搭建个人博客
  • 原文地址:https://www.cnblogs.com/xiaotuni/p/2365761.html
Copyright © 2011-2022 走看看