我在MySQL中运行此查询:
SELECT MAX(arg1) as longest, MIN(arg1) as shortest FROM voipnow.ast_queue_log
WHERE queuename = '0536*401'
AND DATE(time) = '2014-03-17'
AND event = 'CONNECT'
ORDER BY time DESC
但它正在回归:
longest = 9
shortest = 10
我在这里做错了什么? - 他们应该是相反的方式
答案 0 :(得分:2)
看起来这些字段是文本,您正在查找按字母顺序排列的最大/最小值。
“9”> “10”
答案 1 :(得分:0)
您是否尝试过ASC订购?
SELECT MAX(arg1) as longest, MIN(arg1) as shortest FROM voipnow.ast_queue_log
WHERE queuename = '0536*401'
AND DATE(time) = '2014-03-17'
AND event = 'CONNECT'
ORDER BY time ASC
答案 2 :(得分:0)
假设: 它们存储为字符串,“1 ...”<“9 ...”
尝试:
SELECT MAX(arg1 + 0) as longest,
MIN(arg1 + 0) as shortest
FROM voipnow.ast_queue_log
WHERE queuename = '0536*401'
AND DATE(time) = '2014-03-17'
AND event = 'CONNECT'
ORDER BY time DESC