为什么distinct在这里不起作用 [英] Why distinct is not working here
本文介绍了为什么distinct在这里不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT prl.description ,
DISTINCT
convert(varchar,prl.effective_date,103) effective_date,
b.description brand ,
pc.description cat
FROM ProductRateList prl,Products pro,ProductCatg pc, Brands b
WHERE pro.Id = prl.Product_Id AND pc.Id = pro.ProdCatg_Id AND B.Id = pro.Brand_id AND pro.Active = 'Y'
order by prl.effective_date desc,
PRl.description ASC
group by convert(varchar,prl.effective_date,103),prl.description
推荐答案
这可以用作精确的解决方案,该解决方案也将具有按函数顺序和按函数分组的顺序
And this could be used as exact solution which will have the order by and as well as the group by function too
SELECT DISTINCT prl.description ,
convert(varchar,prl.effective_date,103) effective_date,
b.description brand ,
pc.description cat
FROM ProductRateList prl,Products pro,ProductCatg pc, Brands b
WHERE pro.Id = prl.Product_Id AND pc.Id = pro.ProdCatg_Id AND B.Id = pro.Brand_id AND pro.Active = 'Y'
group by convert(varchar,prl.effective_date,103),prl.description , b.description ,
pc.description
ORDER BY prl.Description
order by只能包含具有汇总功能或具有不同功能的列
order by can contain only those column who either have aggregate function or have distinct
这篇关于为什么distinct在这里不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文