若是指定了 SELECT DISTINCT,那麼 ORDER BY 子句中的項就必須出如今選擇列表中。(解決方法及緣由分析)

解決辦法:sqlserver中若是同時用order by和distinct,那order by後面的字段就必須出如今selcet的字段中。這個問題只有在sqlserver中才會有,mysql中是不會有這個問題的。 若是這樣寫會提示錯誤: select distinct name from user order by id 應該這樣寫: select distinct id,name from us
相關文章
相關標籤/搜索