作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
This is the A/B Experiment table with 4 columns:
1. user_id
2. experiment_id
3. experiment_date
4. experiment_type (values are either: test or control - group)
This is the Order table with 3 columns:
1. user_id
2. order_sku
3. order_date
我正在尝试列出订购产品的前 10 位 user_id,并对每个实验 ID 进行排名。
The output Table should look like this:
1. experiment_id
2. Rank
3. user_id
4. experiment_type
5. experiment_date
我该如何在 mySQL 中做到这一点?非常感谢任何帮助!
最佳答案
您将RANK()
与INNER JOIN
一起使用
select RANK() as Rank , experiment_id , user_id , experiment_type , experiment_date
from experiment e
inner join order o
where e.user_id=o.user_id
关于mysql - 如何对订购产品的每个 user_id 排序并列出前 10 个 order_ids?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56621043/
我是 sql 的新手,我从未在 mysql 中使用过变量或条件,但从其他编程语言中知道这一点。几天以来,我试图找到一种对用户分数进行排名的方法。我阅读了很多文章,也阅读了 stackoverflow
我是一名优秀的程序员,十分优秀!