jeudi 7 juillet 2016

mysql query to sort alphabetically group by item with count >1 and count = 1 separately on same list

I have a list of listings with

  1. Texas with count 5
  2. New york with count 6
  3. Alabama with count 4
  4. LA with 1
  5. Boston with 1
  6. Washington with 1

I want to order to

  1. Alabama
  2. Newyork
  3. Texas
  4. Boston
  5. LA
  6. Washington

So anything with count()>1 should be arrange alphabetically to top of list and anything with count()1 should be arrange alphabetically at bottom of list.

Currently i have used

 $orderby = 'counter DESC, display_value ASC';

but its giving me

  1. New york
  2. Texas
  3. Alabama
  4. Boston
  5. LA
  6. Washington

Aucun commentaire:

Enregistrer un commentaire