我有一张这样的 table
我想获取每个表中具有最短响应时间的行
我尝试过这个查询:
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/