首页 > 其他分享 >leetcode 1321 餐館營業額變化增長

leetcode 1321 餐館營業額變化增長

时间:2023-05-17 11:13:07浏览次数:42  
标签:1321 distinct 變化 增長 amount c2 visited c1 select

leetcode 1321 餐館營業額變化增長

select distinct c2.visited_on,
(select sum(amount) from Customer c1
 where c1.visited_on <= c2.visited_on 
 and c1.visited_on >= date_sub(c2.visited_on, interval 6 day)
) as amount,
round((select sum(amount) from Customer c1
 where c1.visited_on <= c2.visited_on 
 and c1.visited_on >= date_sub(c2.visited_on, interval 6 day)
)/7, 2) as average_amount 
from Customer c2
group by c2.visited_on
having c2.visited_on >= date_add(
        (select distinct visited_on from Customer order by visited_on asc limit 0,1)
        , interval 6 day)

==

select c1.visited_on,
       sum(c2.amount)  amount       ,
       round(sum(c2.amount)/7,2)  average_amount from 
(select distinct visited_on
     from customer)
         c1 left join customer c2
on datediff(c1.visited_on,c2.visited_on)<7 and datediff(c1.visited_on,c2.visited_on)>=0
group by  c1.visited_on
having  count(distinct c2.visited_on) = 7

 

标签:1321,distinct,變化,增長,amount,c2,visited,c1,select
From: https://www.cnblogs.com/carlzhang19/p/17407949.html

相关文章

  • kuangbin专题一 简单搜索 棋盘问题(POJ-1321)
    棋盘问题TimeLimit:1000MS MemoryLimit:10000KTotalSubmissions:125427 Accepted:56304Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘......
  • 2023/1/16 20221321杨渝学习打卡
    python入门学习学习链接:https://www.bilibili.com/video/BV14r4y1k7F9/?spm_id_from=333.999.0.0&vd_source=a989a1afa6cb8b6527dd9bf059d71439字典的循环打印(解构)字典......
  • 2023/1/15 20221321杨渝学习打卡
    python学习学习链接:https://www.bilibili.com/video/BV14r4y1k7F9/?spm_id_from=333.999.0.0&vd_source=a989a1afa6cb8b6527dd9bf059d71439对字典的操作字典的使用对......
  • 2023/1/14 20221321杨渝学习打卡
    python学习学习链接:https://www.bilibili.com/video/BV14r4y1k7F9/?spm_id_from=333.999.0.0&vd_source=a989a1afa6cb8b6527dd9bf059d71439元组字典元组元组,英文为t......
  • POJ1321 棋盘问题
    POJ1321棋盘问题在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状......
  • 2023/1/12 20221321杨渝学习打卡
    python入门学习学习链接:https://www.bilibili.com/video/BV14r4y1k7F9/?spm_id_from=333.999.0.0&vd_source=a989a1afa6cb8b6527dd9bf059d71439对集合,列表的操作对集合......
  • 2023/1/11 20221321杨渝学习打卡
    python入门学习学习链接:https://www.bilibili.com/video/BV14r4y1k7F9/?spm_id_from=333.999.0.0&vd_source=a989a1afa6cb8b6527dd9bf059d71439集合列表集合先看c语......
  • 2023/1/10 20221321杨渝学习打卡
    python入门学习学习链接https://www.bilibili.com/video/BV14r4y1k7F9/?spm_id_from=333.999.0.0&vd_source=a989a1afa6cb8b6527dd9bf059d71439if判断while循环布尔......
  • POJ - 1321 棋盘问题
    POJ-1321棋盘问题题解:DFS搜索#include<bits/stdc++.h>#defineZeoystd::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0)#defineall(x)(x).b......
  • 2023/1/9 20221321杨渝学习打卡
    Python入门学习学习链接:https://www.bilibili.com/video/BV14r4y1k7F9/?spm_id_from=333.999.0.0&vd_source=a989a1afa6cb8b6527dd9bf059d71439输入,输出,计算1.输入:在c语......