Using distinct on a column and doing order by on another column gives an error

前端 未结 11 2160
渐次进展
渐次进展 2021-02-05 14:43

I have a table: abc_test with columns n_num, k_str.

This query doesnt work:

    select distinct(n_num) from abc_test order by(k_str)

B

11条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 15:20

    You are selecting the collection distinct(n_num) from the resultset from your query. So there is no actual relation with the column k_str anymore. A n_num can be from two rows each having a different value for k_str. So you can't order the collection distinct(n_num) by k_str.

提交回复
热议问题