根據馬甲、市集、統計每天的註冊量,要求可以根據選擇馬甲和app,馬甲和appstrore和user_login不同表問題

來源:互聯網
上載者:User

標籤:instr   儲存   miss   char   sql   join   order by   登入   bsp   

這個馬甲屬於一個表,appStore另一張表,使用者登入表,主要操作的就是這三個表。

我這裡的馬甲和app的id都與使用者登入表中的channel對應,在channel存放的是majiaId + “|” + storeId

 

第一版sql:

select count(*), sms_tag_name, store_name from               (select             id,             create_date,              SUBSTR(channel,0,NVL(INSTR(channel, ‘|‘, 1,1),0)-1) sms_tag_id,            SUBSTR(channel,NVL(INSTR(channel, ‘|‘, 1,1),0)+1, length(channel)- NVL(INSTR(channel, ‘|‘, 1,1),0)) store_id,            channel             from user_login             where             NVL(INSTR(channel, ‘|‘, 1,1),0) != 0)  u       INNER JOIN majia_sms_tag mst ON  mst.sms_tag_id = u.sms_tag_id       INNER JOIN app_store aps ON aps.store_id = u.store_id       where store_name=‘華為‘       group by sms_tag_name, store_name     

發現存在問題,針對使用者登入中農沒有儲存到的馬甲和市集的註冊量找不出來等,資訊不全面

 

第二版:

select        count(u.id),        sms_tag_name,        store_namefrom        (       select                sms_tag_id,               sms_tag_name,               store_id,               store_name,               concat(concat(sms_tag_id,‘|‘),store_id) as channel        from               majia_sms_tag cross join app_store       ) ma        left join (            select *             from user_login            where                    to_char(create_date, ‘YYYYMMDDHH24MISS‘) >= ‘20160801000000‘                  and to_char(create_date, ‘YYYYMMDDHH24MISS‘) <= ‘20170801000000‘       ) u on u.channel = ma.channelwhere        sms_tag_id=‘com.rybring.weilidai‘        and store_id=‘platf.360‘ group by sms_tag_name,store_nameorder by sms_tag_name,store_name

還是用了cross join,第一次用到擦,並且將兩個查詢的條件分別放在子查詢中和外面。神來之筆。

以後再有類似需求可以參考。

 

根據馬甲、市集、統計每天的註冊量,要求可以根據選擇馬甲和app,馬甲和appstrore和user_login不同表問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.