gpt4 book ai didi

mysql - 简单的最大功能困扰着我

转载 作者:行者123 更新时间:2023-12-01 00:18:31 24 4
gpt4 key购买 nike

简单的查询困扰着我。我似乎做错了,但我知道这很简单:

Select username
From hsi.wftransactionlog
where logdate = (Select max(logdate) From hsi.wftransactionlog)

我想返回具有最高日志日期的用户名。

我正在为每个用户名查找 1 行。日期最长的那个。

最佳答案

I am looking for 1 row per username. The one with the max date.

那么你可能想做一个group by,比如

Select t1.*
From hsi.wftransactionlog t1
join (Select username, max(logdate) as maxlogdate
From hsi.wftransactionlog
group by username) xxx
on t1.username = xxx.username and t1.logdate = xxx.maxlogdate;

关于mysql - 简单的最大功能困扰着我,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42772473/

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