• <menu id="uku4c"><u id="uku4c"></u></menu>
  • <input id="uku4c"><u id="uku4c"></u></input>
  • <menu id="uku4c"></menu><menu id="uku4c"><acronym id="uku4c"></acronym></menu>
  • <menu id="uku4c"><tt id="uku4c"></tt></menu>
  • <menu id="uku4c"></menu>
  • <nav id="uku4c"><tt id="uku4c"></tt></nav>
  • 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.hz0j2r6vo.fun http://fa.hz0j1r1vo.fun http://fa.hz0j0r4vo.fun http://fa.hz0j2r7vo.fun http://fa.hz0j0r5vo.fun