开发者

LIMIT 3 not returning the first three rows in sorted RS (I think)

In my table I have looked manually and found that the top three idle units have been idle for 17, 13 and 13 days. When I use this SQL statement to try and pull the three rows with the highest idle column value, I don't get these numbers, I get 8, 7 and 7. Is there some other command I should use to grab the first 3 rows of a sorted resultset?

SELECT * FROM reporttables.idlereport WHERE LEFT(depot,3)='Roc' ORDER BY idle DESC LIMIT 3

Can anyon开发者_StackOverflow中文版e help me figure out what is wrong with this statement


Is the 'idle' field of a numeric or a char data type?

The sort order you found suggests char, then "7" could be 'greater than' "17".

You might then be able to cast the char data with some sort of CONVERT. Exact syntax depends on your RDBMS type.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜