select i.id, i.name, i.group_id, i.max_people, i.create_time, u.nick_name, w.shrimp, gb.total, gpo.order_total, gpo.rake_total, gpo.shell_total, gpo.consume_total from im_group_information i left join im_group g on g.group_id = i.group_id and g.admin=2 left join (select group_id, count(group_id) total from im_group where is_delete=0 group by group_id) gb on gb.group_id = i.group_id left join (select bid, count(bid) order_total, sum(rake) rake_total, sum(price) shell_total, count(distinct uid) consume_total from g_prop_order where is_delete=0 group by bid) gpo on gpo.bid = g.u_id left join u_user u on u.id = g.u_id left join u_wallet w on w.id = g.u_id left join (select uid, count(distinct uid) offline_total from u_online_log group by uid) l on g.u_id = l.uid where i.is_delete = 0;怎么查到im_group_information群组表中七天内登陆过的用户数量
时间: 2023-12-21 13:04:24 浏览: 131
I2c.rar_i2c_i2c.c
可以使用子查询结合条件判断的方式来查询七天内登陆过的用户数量,具体实现如下:
```
SELECT COUNT(DISTINCT l.uid) AS login_total
FROM im_group_information i
LEFT JOIN im_group g ON g.group_id = i.group_id AND g.admin = 2
LEFT JOIN u_user u ON u.id = g.u_id
LEFT JOIN u_online_log l ON g.u_id = l.uid
WHERE i.is_delete = 0
AND l.login_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
```
这里使用了 `COUNT(DISTINCT l.uid)` 来统计七天内登陆过的用户数量,同时在 `WHERE` 子句中加入条件 `l.login_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)` 来筛选出七天内登陆过的用户。
阅读全文