特定データ順に並び替える

  • サンプルデータ

datas
1
2
3
4

  • datasを3,4,1,2の順に並び替えるSQL

 select datas from [TABLE_NAME]  order by datas = '3' desc, datas = '4' desc, datas = '1' desc, datas = '2' desc ;

datas
3
4
1
2

  • 重複があるサンプルデータ

datas
1
1
2
2
3
3
4
4

  • datasを3,4,1,2の順に並び替えて、重複を表示しないように表示するSQL

 select datas from [TABLE_NAME] group by datas order by datas = '3' desc, datas = '4' desc, datas = '1' desc, datas = '2' desc ;

datas
3
4
1
2


2010-07-26

最終更新:2010年07月26日 01:36
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。