以步数排行榜为例
关键词:小程序开发,云函数,多表联接,left join,分组聚合,分组统计,分组求和
- user表(存储用户基本信息)
open_id | name | head_url |
---|
1 | 张三 | http://www.xxx.com/img1 |
2 | 李四 | http://www.xxx.com/img2 |
3 | 王五 | http://www.xxx.com/img3 |
- step表(存储用户的历史步数)
open_id | step_nums | create_time |
---|
1 | 1111 | 20xx/xx/xx |
1 | 2222 | 20xx/xx/xx |
2 | 3333 | 20xx/xx/xx |
- thumbs表(存储排名点赞数据)
open_id | fans_id | create_time |
---|
1 | 2 | 20xx/xx/xx |
1 | 3 | 20xx/xx/xx |
2 | 3 | 20xx/xx/xx |
- 查询结果
open_id | name | head_url | steps | thumbs_num |
---|
1 | 张三 | http://www.xxx.com/img1 | 3333 | 2 |
2 | 李四 | http://www.xxx.com/img2 | 3333 | 1 |
3 | 王五 | http://www.xxx.com/img3 | 0 | 0 |