select asin,
area as "备货区域",
sum(case when purchase_date >= trunc(sysdate) - 7 then sales_num else 0 end ) as "近7天销量",
sum(case when purchase_date >= trunc(sysdate) - 30 then sales_num else 0 end ) as "近30天销量",
sum(case when purchase_date >= trunc(sysdate) - 60 then sales_num else 0 end ) as "近60天销量",
sum(case when purchase_date >= trunc(sysdate) - 90 then sales_num else 0 end ) as "近90天销量"
from ( select purchase_date,
asin,
(case when sys_site in ('DE','IT','ES','FR') then 'EU'
when sys_site = 'UK' then 'UK'
when sys_site in ('US','MX') then 'UX'
when sys_site = 'CA' then 'CA'
when sys_site = 'SG' then 'SG'
when sys_site = 'AU' then 'AU'
else null end ) as area,
sales_num
from bi_sales
group by asin, area
下面是编程之家 jb51.cc 通过网络收集整理的代码片段。编程之家小编现在分享给大家,也给大家做个参考。话说有一文章表article,存储文章的添加文章的时间是add_time字段,该字段为int(5)类型的,现需要查询今天添加的文章总数并且按照时间从大到小排序,则查询语句如下:1 select * from `article` where date_format(from_UNIXTIME(`...
一、汇总分析常用的汇总分析函数有下面几种。例如从成绩表中查询成绩求和(所用数据表在第一课已共享)select sum(成绩)
from score;从成绩表中查询成绩平均值select avg(成绩)
from score;从成绩表查询成绩最大值和最小值select max(成绩),min(成绩)
from score;二、分组SQL分组:group byselect 性别,count(*)
需求:查询最近30天每天的业绩总和(当天没有业绩的默认为0)1.刚开始我的sql是这样写的:SELECT truncate(sum(af2.money),2) as m,DATE_FORMAT(af2.create_date,'%Y-%m-%d') as gptime from financial_flow af2,vip_student vs1where af2.ACCOUNT_NO IN ('...
curdate( ) AS date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 1 DAY ) AS date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 2 DAY ) AS date UNION ALL
SELECT
date_su
$time = time();
$today = strtotime(date('Y-m-d', time()));//零点时间戳
$todayDate = date('Y-m-d', time());
//最近7天
$sevenDaysAgo = strtotime(date('Y-m-d', time())) - 7 * 86400;
$sql = "SELECT
t1.day,
COUNT(t2.id) user_num
插入数据:
INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');
INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS')...
开窗olap转自 https://www.cnblogs.com/sooner/p/7735154.html
range和row的区别转自 http://www.cnblogs.com/woodytu/p/4709020.html
Oracle分析函数-OLAP函数总结
ORACLE OLAP 函数
最近这个东东用得特别多,总结了一下 。
语法: FUNCTION_...
curdate( ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 1 DAY ) AS click_date UNION ALL
SELECT
date_s