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

前端 未结 11 2186
渐次进展
渐次进展 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:34

    My query doesn't match yours exactly, but it's pretty close.

    select distinct a.character_01 , (select top 1 b.sort_order from LookupData b where a.character_01 = b.character_01 )
    from LookupData a 
    where 
    Dataset_Name = 'Sample' and status = 200
    order by 2, 1
    

提交回复
热议问题