<address id="9vp7r"></address>

    
    
      <sub id="9vp7r"></sub><thead id="9vp7r"></thead>

          <address id="9vp7r"></address>

          <sub id="9vp7r"></sub>

          <sub id="9vp7r"></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
          相关文章
          相关标签/搜索
          每日一句
            每一个你不满意的现在,都有一个你没有努力的曾经。
          公众号推荐
             一个历史类的公众号,欢迎关注
          一两拨千金
          4987铁算结果开奖结果小说 南靖县| 庄河市| 呼和浩特市| 连平县| 桐庐县| 西乌| 彭阳县| 崇明县| 馆陶县| 贡山| 河北区| 井陉县| 富宁县| 安宁市| 宝鸡市| 云林县| 陵水| 北碚区| 明溪县| 河东区| 博兴县| 嘉荫县| 利辛县| 南康市| 班戈县| 井陉县| 乌海市| 石狮市| 武强县| 图木舒克市| 隆回县| 津市市| 巴彦县| 阳原县| 遵义市| 门头沟区| 麻栗坡县| http://fa.hz0j1r3vo.fun http://fa.hz0j1r6vo.fun http://fa.hz0j0r1vo.fun http://fa.hz0j0r6vo.fun http://fa.hz0j0r2vo.fun