Sort records in random order for specific group of data using MySQL select query

Viewed 522

I have a below db table structure :

Tablename : agency_mst
Fields:
id
name
is_premium
date_added

I want to sort the data so that the agencies with is_premium=1 comes first and the rest of the data is sorted by date_added desc order.

But also the is_premium=1 records should be sorted in random order. so first set of premium agencies will have random order. How can I do that using MySQL Select query.

I have built this query partially but not sure how to filter specific set of data. Below is that query:

SELECT * FROM agency_mst
ORDER BY is_premium DESC, date_added DESC
3 Answers
Related