This vest belongs to a table, appstore another table, the user login table, the main operation is the three tables.
The ID of my vest and app here corresponds to the channel in the User login table, where the channel is Majiaid + "|" + storeId
First edition of SQL:
SelectCOUNT (*), Sms_tag_name, Store_name from (SelectID, 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 fromUser_loginwhereNVL (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_idwhereStore_name='Huawei'GROUP by Sms_tag_name, Store_name
Found that there is a problem, the user login to the farmer does not store the vest and the application store registration amount can not be found, etc., information is not comprehensive
Second Edition:
Selectcount (u.id), Sms_tag_name, Store_name from ( Selectsms_tag_id, Sms_tag_name, store_id, Store_name, Concat (Concat (sms_tag_id,'|'), store_id) asChannel fromMajia_sms_tag Cross join App_store) Ma left join (Select* fromUser_loginwhereTo_char (Create_date,'Yyyymmddhh24miss') >='20160801000000'and To_char (Create_date,'Yyyymmddhh24miss') <='20170801000000') u on U.channel=Ma.channelwheresms_tag_id='Com.rybring.weilidai'and store_id='platf.360'GROUP by Sms_tag_name,store_nameorder by Sms_tag_name,store_name
The cross join is used, the first wipe is used, and the conditions of the two queries are placed in the subquery and the outside. Genius
Later there are similar requirements can be consulted.
Depending on the vest, the store, the number of registrations per day, the requirements can be based on the choice of vests and apps, vests and appstrore and user_login different table issues