开发者

move one row to the end of a result set in MySQL

I would like to move a row to the bottom of the result set given a matched condition.

Database

+-------+------------+
|Symbol | Percentage |
|-------|------------|
|VG     | 20         |
|-------|------------|
|CASH   | 20         |
|-------|------------|
|GOOG   | 60         |
+-------+------------+

ex: SELECT * FROM TableName -SEND TO END OF RESULT SET- WHERE symbol = 'CASH'

result set:

GOOG
VG
CASH

To clarify my original question...

I ne开发者_JAVA技巧ed to write an exception for an ORDER BY statement. To put the query into plain english - SELECT an entire row, ordering by a timestamp, except if the symbol is "CASH"


To change the order of the rows in a result set you should use ORDER BY:

SELECT *
FROM TableName
ORDER BY symbol = 'CASH', timestamp
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜