我的表包含国家,城市,街道,门号等。在每条街道我都有三种类型的地址。其中一个是主要(永久),其他是替换(临时)1和替换(临时)2。
我想按城市和街道订购
我的结果如下:
City street address type
sincan plevne street replacement1
sincan plevne street main
sincan plevne street replacement2
sincan bosna street replacement2
sincan bosna street main
sincan bosna street replacement1
sincan yazi street replacement2
sincan yazi street replacement1
sincan yazi street main
但是我想订购它们就像跟随它一样。
sincan plevne street main
sincan plevne street replacement1
sincan plevne street replacement2
sincan bosna street main
sincan bosna street replacement1
sincan bosna street replacement2
sincan yazi street main
sincan yazi street replacement1
sincan yazi street replacement2
有可能吗?
由于
答案 0 :(得分:0)
在CASE
子句
ORDER BY
表达式
ORDER BY city, street,
CASE adress_type
WHEN 'main' THEN 1
WHEN 'replacement1' THEN 2
WHEN 'replacement2' THEN 3
ELSE 4
END