如果指定了 SELECT DISTINCT,那么 ORDER BY 子句中的项就必须出现在选择列表中。

tglflzqlmy tglflzqlmy 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区


select DISTINCT a.ID,a.sex,a.NickName,a.Work_location,a.Birth,a.Height,a.Home_location,a.Income,a.Marriage,a.Industry,a.Education from UserPhoto b ,UserBase a left join ZhiJianPaiMing c
on a.id=c.userid and getdate()>c.starttime and getdate()<c.endtime where a.ID=B.UserID and a.Sex =1 Order By case when c.id is null then 1 else 0 end,a.addTime

这个SQL语名,如果加上了DISTINCT就报错,

(如果指定了 SELECT DISTINCT,那么 ORDER BY 子句中的项就必须出现在选择列表中。)
如果去掉DISTINCT就多了许多得复的结果

唉,老外开发的程试就难理解,晕,哪个高手帮下

...全文
评论 14
收藏 已收藏
分享
返回顶部
tglflzqlmy
疑难问题 22,298 成员 121,727 内容