[ SQL ] order by specific type

If we would like currency_code=’GBP’ comes first, use the following query.

book.prices.order("`currency_code` = 'GBP' desc, currency_code")

NOTICE : there is a desc in the query!!!!

ref : https://stackoverflow.com/questions/17637983/order-alphabetically-but-with-one-value-at-the-top

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s