tags:

views:

22

answers:

1

Hi,

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 need 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"

+6  A: 

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

SELECT *
FROM TableName
ORDER BY symbol = 'CASH', timestamp
Mark Byers
nice ...but maybe it should be "ORDER BY (symbol='CASH'), timestamp" (or something) so the order of the other rows will be deterministic.
Ollie Jones
@Ollie Jones: You are right - the question was changed since I posted my answer. I've updated it now.
Mark Byers
thank you very much. this is exactly what I need.
Derek Adair