我需要以某种方式列出字段,但对其进行不同的排序。这是查询。有什么方法吗?
SELECT DISTINCT tsgroup
FROM master
ORDER BY RIGHT(RTRIM(tsgroup), 3),
LEFT(rtrim(tsgroup), 3)
答案 0 :(得分:9)
您可以使用GROUP BY
代替
SELECT tsgroup
FROM master
GROUP BY tsgroup
ORDER BY RIGHT(RTRIM(tsgroup), 3),
LEFT(RTRIM(tsgroup), 3)
答案 1 :(得分:0)
select grp from (
select distinct tsgroup as grp
from master
)
order by RIGHT(RTRIM(grp), 3) , left(rtrim(grp), 3)