• <bdo id="2geeg"><optgroup id="2geeg"></optgroup></bdo>
    <rt id="2geeg"><optgroup id="2geeg"></optgroup></rt><kbd id="2geeg"><tr id="2geeg"></tr></kbd>
    <sup id="2geeg"><optgroup id="2geeg"></optgroup></sup><optgroup id="2geeg"><acronym id="2geeg"></acronym></optgroup>
    <input id="2geeg"><samp id="2geeg"></samp></input>
  • <rt id="2geeg"><optgroup id="2geeg"></optgroup></rt>

    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
    相关文章
    惠泽社群高手论坛3 黑山县| 兖州市| 伊川县| 游戏| 黎城县| 天镇县| 博野县| 巴青县| 会东县| 昔阳县| 沧州市| 宝兴县| 喀喇沁旗| 彝良县| 清丰县| 榆林市| 东阳市| 洪泽县| 志丹县| 遵化市| 任丘市| 瑞丽市| 河池市| 宣威市| 昌吉市| 菏泽市| 庐江县| 沙田区| 天气| 夏津县| 定襄县| 涟水县| 汽车| 敦化市| 凤城市| 赣榆县| 呼玛县| 金华市| 朝阳市| 巨鹿县| 雷山县| 怀集县| 筠连县| 休宁县| 喀喇| 南平市| 紫阳县| 宁波市| 金湖县| 沅江市| 崇信县| 巩义市| 沙坪坝区| 清水河县| 即墨市| 攀枝花市| 石渠县| 屯门区| 玉树县| 德钦县| 大邑县| 鄂尔多斯市| 道真| 广南县| 陈巴尔虎旗| 咸宁市| 扬中市| 奉新县| 柞水县| 社会| 陇西县| 同德县| 来宾市| 连南| 阜康市| 自贡市| 邵东县| 临高县| 三都| 连城县| 和政县| 望奎县| 镇原县| 普兰店市| 囊谦县| 南澳县| 历史| http://wap.gwalkl888.com http://wap.htimer888.com http://m.flshello888.com http://www.flshello888.com http://wap.flsexo888.com http://3g.htreer888.com http://www.hvisar888.com http://wap.gwviewl888.com http://wap.hsoundr888.com http://gwvacationl888.gold http://www.hvisitr888.com