|
-
Oct 14th, 2006, 12:19 PM
#1
Thread Starter
Hyperactive Member
no group by or distinct in SQL Server?!
It seems that SQL Server that comes with VS 05 has never heard of DISTINCT clause. Normally it's DISTINCT(columnname) but it has no idea what that means. And the other function that would get rid of duplicates, GROUP BY doesn't work either. I put it in and it just says error by the word group. I wrote the whole statement a little different and it says "Column dbo.tblResults.UserID is invalid in the select list because it is not contained in either an aggregate function or the group by clause" and of course it says that when I put it in the group by clause and it's also in the select clause too so that's a stupid error message. Here's the two statements that don't work for some reason. If anyone knows why, that'd be great:
SELECT TOP (100) PERCENT dbo.tblResults.UserID, dbo.tblUser.UserName, dbo.tblQuiz.Description
FROM dbo.tblResults INNER JOIN
dbo.tblUser ON dbo.tblResults.UserID = dbo.tblUser.UserID INNER JOIN
dbo.tblQuiz ON dbo.tblResults.QuizID = dbo.tblQuiz.QuizID
WHERE (dbo.tblUser.IsInstructor = 'false')
GROUP BY dbo.tblResults.UserID
ORDER BY dbo.tblResults.UserID, dbo.tblQuiz.Description
SELECT TOP (100) PERCENT DISTINCT(dbo.tblResults.UserID), dbo.tblUser.UserName, dbo.tblQuiz.Description
FROM dbo.tblResults INNER JOIN
dbo.tblUser ON dbo.tblResults.UserID = dbo.tblUser.UserID INNER JOIN
dbo.tblQuiz ON dbo.tblResults.QuizID = dbo.tblQuiz.QuizID
WHERE (dbo.tblUser.IsInstructor = 'false')
ORDER BY dbo.tblResults.UserID, dbo.tblQuiz.Description
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|