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  表里面放着每个销售员每个月的销售情况

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

    上面这种法子可以实现。

  • 相关阅读:
    在Myeclipse中配置tomcat
    tomcat用startup.bat启动时,界面一闪消失
    单向链表的基本操作
    简单排序的对比
    关于string的排序 选择插入排序
    insertsort
    selectsort
    理解函数式编程
    vue中使用$nextTick后任然无法正确计算出元素高度
    使用vuex+vue-i18n方式国际化
  • 原文地址:https://www.cnblogs.com/xiaotuni/p/2365761.html
Copyright © 2011-2022 走看看