Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
chava_sree
Yak Posting Veteran
56 Posts |
Posted - 2008-03-27 : 19:37:07
|
| how do i use group by for the below query, am getting duplicate results for the query i execute, am not sure how do i use group by for this. pls.help.SELECT C.USER_ID, A.comm_Name, B.UU_TITLE, FILENAME_URL=(Case When UU_Type = 'U' Then UU_url else UU_Filename End), C.User_FirstName + ' ' + C.User_LastName AS Author, Convert(CHAR(10),UU_TimeStamp,101) as DateCreated, Convert(CHAR(10),UU_LastModified,101) as DateModified, uu_AssocAuID, DOWNLOADS = (select count(*) from Vportaldevstats.[dbo].stats_download A where A.stat_AuID = b.UU_AssocAuID ) FROM vportaldev.dbo.community A INNER JOIN vportaldev.[dbo].user_upload B ON A.comm_CreatorUserID = B.UU_USERIDINNER JOIN vportaldev.[dbo].[user] C ON C.user_id = B.UU_USERIDthaks in advance |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-03-27 : 20:25:46
|
| You need aggregate function to use group bySELECT distinct C.USER_ID, A.comm_Name,B.UU_TITLE,FILENAME_URL=(Case When UU_Type = 'U' Then UU_url else UU_Filename End),C.User_FirstName + ' ' + C.User_LastName AS Author,Convert(CHAR(10),UU_TimeStamp,101) as DateCreated,Convert(CHAR(10),UU_LastModified,101) as DateModified,uu_AssocAuID, DOWNLOADS = (select count(*) from Vportaldevstats.[dbo].stats_download A where A.stat_AuID = b.UU_AssocAuID ) FROM vportaldev.dbo.community AINNER JOIN vportaldev.[dbo].user_upload BON A.comm_CreatorUserID = B.UU_USERIDINNER JOIN vportaldev.[dbo].[user] CON C.user_id = B.UU_USERID |
 |
|
|
|
|
|
|
|