gpt4 book ai didi

mysql - 如何对订购产品的每个 user_id 排序并列出前 10 个 order_ids?

转载 作者:行者123 更新时间:2023-11-29 09:41:01 27 4
gpt4 key购买 nike

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com