zoukankan      html  css  js  c++  java
  • MYSQL 复制表

    create table wa_amount as select

        -> sum(case when amount<1000 then 1 else 0 end) as'0-999' ,

        -> sum(case when amount<2000 && amount >999 then 1 else 0 end) as'1000-1999' ,

        -> sum(case when amount<3000 && amount >1999 then 1 else 0 end) as'2000-2999' ,

        -> sum(case when amount<4000 && amount >2999 then 1 else 0 end) as'3000-3999' ,

        -> sum(case when amount < 5000 && amount >3999 then 1 else 0 end) as'4000-4999' ,

        -> sum(case when amount < 6000 && amount >4999 then 1 else 0 end) as'5000-5999' ,

        -> sum(case when amount < 7000 && amount >5999 then 1 else 0 end) as'6000-6999' ,

        -> sum(case when amount < 8000 && amount >6999 then 1 else 0 end) as'7000-7999' ,

        -> sum(case when amount < 9000 && amount >7999 then 1 else 0 end) as'8000-8999' ,

        -> sum(case when amount < 10000 && amount >8999 then 1 else 0 end) as'9000-9999'

        -> from sortamount;

    用as 只复制结构、数据

    用like,会复制所有,包括索引、外键;

  • 相关阅读:
    实验任务四
    java语言基础第二讲 课程作业02 总结
    java 计算精度处理
    构建之法阅读笔记02
    周活动总结表
    周进度条
    构建之法阅读笔记01
    四则运算软件需求规格说明书
    四则运算2
    周进度条
  • 原文地址:https://www.cnblogs.com/07byte/p/5823650.html
Copyright © 2011-2022 走看看