如何在SQL中进行分组? [英] How to do group by in SQL?
本文介绍了如何在SQL中进行分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在下面的查询中添加group by子句
I want to add group by clause on below query
SELECT TOP 10 * FROM
(
SELECT *
FROM
(
SELECT Univadis2_Articles.ArticleID,
Univadis2_Articles.Title,
dbo.StripHTMLTags(Univadis2_Articles.Long_Resume) As SubSection,
dbo.StripHTMLTags(Univadis2_Articles.Short_Resume) As Section,
Univadis2_Articles.ExternalLink
FROM Univadis2_Articles
INNER JOIN Univadis2_ContentServices
ON Univadis2_Articles.ContentServiceNodeID = Univadis2_ContentServices.NodeID AND Univadis2_ContentServices.Title= 'MIMS' WHERE 1=1 And dbo.Univadis2_Articles.Long_Resume IS NOT NULL AND dbo.Univadis2_Articles.Short_Resume IS NOT NULL AND (Univadis2_Articles.Title LIKE '%twist%' OR Univadis2_Articles.Keywords LIKE '%twist%')
) Univadis2_Articles
) Univadis2_Articles
Order By Cast(Section As Varchar(100)), Cast(SubSection As Varchar(100))
上面的查询过后,任何人都可以帮我吗,它显示重复的数据..我想用Univadis2_Articles.Title字段将它们分组.
can any one plz help me, after wxecution above query it shows the duplicate data.. i want to group by them with Univadis2_Articles.Title field.
推荐答案
请确保联接具有所有必填字段,以避免重复数据.另请参见以下按技术分组的链接:
http://weblogs.sqlteam.com/jeffs/archive/2005/12/14/8546.aspx [ ^ ]
Please make sure that joins has all the required fields to avoid duplicate data. Also see the following link on different group by techniques:
http://weblogs.sqlteam.com/jeffs/archive/2005/12/14/8546.aspx[^]
这篇关于如何在SQL中进行分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文