zoukankan      html  css  js  c++  java
  • SQL语句统计每天、每月、每年的 数据

    原文

    1、每年
    select year(ordertime) 年,
    sum(Total) 销售合计
    from 订单表
    group by year(ordertime)
     
    2、每月
    select year(ordertime) 年,
    month(ordertime) 月,
    sum(Total) 销售合计
    from 订单表
    group by year(ordertime),
    month(ordertime
     
    3、每日
    select year(ordertime) 年,
    month(ordertime) 月,
    day(ordertime) 日,
    sum(Total) 销售合计
    from 订单表
    group by year(ordertime),
    month(ordertime),
    day(ordertime)
     
    另外每日也可以这样:
    select convert(char(8),ordertime,112) dt,
    sum(Total) 销售合计
    from 订单表
    group by convert(char(8),ordertime,112)
    
  • 相关阅读:
    String和stringbuffer
    项目中Orcale存储过程优化记录
    大数据项目中的Oracle查询优化
    洛谷P3402 可持久化并查集
    Gym
    CodeForces
    Gym
    Gym
    UVA
    Kattis
  • 原文地址:https://www.cnblogs.com/haima/p/13518087.html
Copyright © 2011-2022 走看看