gpt4 book ai didi

mysql - 如何使用矩阵顺序选择顶部不同的值

转载 作者:行者123 更新时间:2023-11-29 10:46:50 25 4
gpt4 key购买 nike

我有一张这样的 table

enter image description here

我想获取每个表中具有最短响应时间的行

我尝试过这个查询:

select tablename,
index1,
index2,
min(responsetime)
from tableconf
group by tablename
order by responsetime asc

但它没有给出我想要的

我想要的输出是

+------------------+------------------+--------+--------------+
| tablename | index1 | index2 | responsetime |
+------------------+------------------+--------+--------------+
| salesorderheader | TotalDue | NULL | 6.1555 |
| salesterritory | Name | NULL | 11.66667 |
| store | BusinessEntityId | Name | 3.6222 |
| previous | previous | NULL | 5.03333 |
| NONE | NONE | NULL | 5.6 |
+------------------+------------------+--------+--------------+

我应该使用什么查询来获取我想要的输出

最佳答案

选择每个表名称的最短日期。对这些使用 IN 子句来获取行:

select *
from tableconf
where (tablename, responsetime) in
(
select tablename, min(responsetime)
from tableconf
group by tablename
);

关于mysql - 如何使用矩阵顺序选择顶部不同的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44417225/

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