实施MIN或获得最低记录
我想寻求有关如何解决此问题的帮助。我想添加 MIN 或某种查询,以仅显示下面 SQL 查询的 TotalTime 基础上的最低数字。
查询正在运行,但它显示重复的数据,我只想获得最低的 TotalTime。
提前致谢。
SELECT DISTINCT t1.name,
t1.Description,
t1.Issue,
t1.Dateres AS ATime,
t2.Dateres AS BAck,
TIMEDIFF(t2.Dateres,t1.Dateres) AS TotalTime,
t2.Acknowledge, t2.Resolution
FROM t1
LEFT JOIN t2 ON t1.name = t2.name
AND t1.IPAddress = t2.IPAddress
AND t1.Description = t2.Description
AND t1.Issue = t2.Issue
AND t1.Severity = t2.Severity
AND t1.Timestamp = t2.Timestamp
WHERE t1.Dateres IS NOT NULL
AND t2.Dateres IS NOT NULL
AND t2.Acknowledge = '[email protected]'
AND t2.Dateres >= '2011-10-18 00:00:00'
AND t2.Dateres <= '2011-10-23 23:59:59'
GROUP BY ATime
ORDER by BAck ASC;
I would like to ask for help on how to fix this. I would like to add a MIN or some sort of query to only show lowest number on the TotalTime base on the SQL query below.
The query is working but it show duplicate data and I only want to get the lowest TotalTime.
Thanks in advance.
SELECT DISTINCT t1.name,
t1.Description,
t1.Issue,
t1.Dateres AS ATime,
t2.Dateres AS BAck,
TIMEDIFF(t2.Dateres,t1.Dateres) AS TotalTime,
t2.Acknowledge, t2.Resolution
FROM t1
LEFT JOIN t2 ON t1.name = t2.name
AND t1.IPAddress = t2.IPAddress
AND t1.Description = t2.Description
AND t1.Issue = t2.Issue
AND t1.Severity = t2.Severity
AND t1.Timestamp = t2.Timestamp
WHERE t1.Dateres IS NOT NULL
AND t2.Dateres IS NOT NULL
AND t2.Acknowledge = '[email protected]'
AND t2.Dateres >= '2011-10-18 00:00:00'
AND t2.Dateres <= '2011-10-23 23:59:59'
GROUP BY ATime
ORDER by BAck ASC;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
希望这会起作用:::
Hope this will work:::