Click here to Skip to main content
15,899,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to add group by clause on below query
SQL
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))

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.
Posted
Updated 13-Jan-12 0:05am
v2

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900