开发者

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

开发者 https://www.devze.com 2023-01-14 08:17 出处:网络
I would like to move a row to the bottom of the result set given a matched condition. Database +-------+------------+

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

精彩评论

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

关注公众号