
如圖所示,謝謝大神們!
uj5u.com熱心網友回復:
計算兩個資料相除select (select sum(a) from xx)/(select sum(b) from xx) from dual;
格式化為兩位小數decimal=2
select convert(4545.1366,decimal);
僅供參考,你自己寫出來的印象會深一點。
不提供完整sql
uj5u.com熱心網友回復:
這個是回頭人數
select a.fdate as actfdate, b.fdate as backfdate, count(a.uid) as backCnt from
(SELECT fdate, uid from table where fdate >= startA and fdate < endA) as a,
(SELECT fdate, uid from table where fdate >= startB and fdate < endB) as b
where a.uid = b.uid and a.fdate < b. fdate group by actfdate, backfdate
這是當天活躍
select fdate, count(uid) as actCnt from table where fdate >= startA and fdate < endA group by fdate
這兩個表連接 就求出回頭率了
還有表結構, uid 為什么用string ?一般不是int 或者bigint嗎? 然后 啟動時長, 一天才 8w多秒, 為什么用bigint, 啟動次數也是, 還有日期, 為什么用string? 不用int?
uj5u.com熱心網友回復:
select *,concat(round(100 * 次日留存用戶數/活躍用戶數, 2), '%') 次日留存率,
concat(round(100 * 三日留存用戶數/活躍用戶數, 2), '%') 三日留存率,
concat(round(100 * 七日留存用戶數/活躍用戶數, 2), '%') 七日留存率
from (
select a.dayno 日期,
count(distinct a.uid) 活躍用戶數,
count(distinct b.uid) 次日留存用戶數,
count(distinct c.uid) 三日留存用戶數,
count(distinct d.uid) 七日留存用戶數
from act_user_info a
left join act_user_info b on a.uid = b.uid and b.dayno = a.dayno + 1
left join act_user_info c on a.uid = c.uid and c.dayno = a.dayno + 3
left join act_user_info d on a.uid = d.uid and d.dayno = a.dayno + 7
group by a.dayno
) p;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/35038.html
標籤:MySQL
