<address id="rf17h"><dfn id="rf17h"></dfn></address>
    <address id="rf17h"><var id="rf17h"></var></address> <sub id="rf17h"><var id="rf17h"><ins id="rf17h"></ins></var></sub><address id="rf17h"></address>

    <address id="rf17h"><listing id="rf17h"><ins id="rf17h"></ins></listing></address>

    <sub id="rf17h"><var id="rf17h"></var></sub>
    <sub id="rf17h"><var id="rf17h"><output id="rf17h"></output></var></sub>

      <address id="rf17h"></address>
      <sub id="rf17h"><var id="rf17h"></var></sub>
          <sub id="rf17h"><dfn id="rf17h"><ins id="rf17h"></ins></dfn></sub>

          MySQL 案例:计算环比

          select a.day_num as "序号",
                 a.create_time as "上架时间",
                 a.clue_num as "上架车源量",
                ((a.clue_num/b.clue_num)-1) as "环比"
          from
          (
              select cast(date_diff(day,cast(2019-01-01 as timestamp),a.create_time) as int) as day_num,
                     a.create_time,
                     a.clue_num
              from
              (
                    SELECT
                     --substr(create_time,1,7) as year_mo,
                     date(from_unixtime(to_unixtime(cast(create_time as timestamp)))) as create_time,
                     cast(count(distinct clue_id) as double) as clue_num
                    FROM guazi_dw_dwd.dim_com_car_source_ymd as a
                    WHERE dt = CAST(date_add(day, -1, current_date) AS VARCHAR)
                    and substr(create_time,1,10) between ${date1} and ${date2}
                    AND platform in (2,3)
                    group by 1
              )a
          )a
          left join
          (
              select cast(date_diff(day,cast(2019-01-01 as timestamp),a.create_time) as int) as day_num,
                     a.create_time,
                     a.clue_num
              from
              (
                    SELECT
                     --substr(create_time,1,7) as year_mo,
                     date(from_unixtime(to_unixtime(cast(create_time as timestamp)))) as create_time,
                     cast(count(distinct clue_id) as double) as clue_num
                    FROM guazi_dw_dwd.dim_com_car_source_ymd as a
                    WHERE dt = CAST(date_add(day, -1, current_date) AS VARCHAR)
                    and substr(create_time,1,10) between ${date1} and ${date2}
                    AND platform in (2,3)
                    group by 1
              )a
          )b
          on a.day_num = b.day_num + 1
          order by 1 asc
          相关文章
          相关标签/搜索
          每日一句
            每一个你不满意的现在,都有一个你没有努力的曾经。
          公众号推荐
             一个历史类的公众号,欢迎关注
          一两拨千金
          王中王中特免费公开资料选料 喀喇| 施秉县| 通州区| 河南省| 肃南| 菏泽市| 秭归县| 大邑县| 宜城市| 台安县| 宣汉县| 苏州市| 旅游| 陆川县| 五河县| 凤凰县| 华安县| 霍林郭勒市| 田林县| 敦煌市| 玛纳斯县| 修武县| 贺州市| 江山市| 育儿| 临高县| 新乐市| 江永县| 伊金霍洛旗| 措勤县| 海伦市| 扶沟县| 克什克腾旗| 黄冈市| 龙岩市| 新干县| 九江市| http://fa.hz0j0r9vo.fun http://fa.hz0j1r2vo.fun http://fa.hz0j1r3vo.fun http://fa.hz0j0r4vo.fun http://fa.hz0j2r8vo.fun