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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 need help with group by

Author  Topic 

siegblazer
Starting Member

5 Posts

Posted - 2007-06-21 : 00:56:16
hi everyone, i got this error when i excute the following codes.

select t.blnIsMarkedAsDeletedTR 'IsMarkedAsDeleted',t.intRegistrationIdTR 'RegistrationId',s.strNameSC 'School',Sa.strTitleSA + '. ' + t.strTeacherFullNameTR 'Teacher in Charge',c.strNameCC'Competition Category',Sas.strTitleSA + '. ' + st.strFullNameST 'Team Members'
from tblCompetitionCategory c, tblSalutation sa, tblSchool s, tblTeamRegistration t,tblStudent st,tblSalutation sas
where s.intSchoolIdSC = t.intSchoolIdTR
AND t.intTeacherSalutationIdTR=sa.intSalutationIdSA
And t.intCompetitionCategoryIdTR = c.intCompetitionCategoryIdCC
And t.intRegistrationIdTR =st.intRegistrationIdST
And sas.intSalutationIdSA = st.intSalutationIdST
and t.intCompetitionCategoryIdTR ='1'
group by t.intRegistrationIdTR

Msg 8120, Level 16, State 1, Line 1
Column 'tblTeamRegistration.blnIsMarkedAsDeletedTR' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-21 : 01:12:37
remove the GROUP BY line. You don't need it there, you are not using any aggregate function like sum(), min(), max() etc

what are you trying to achieve here ?



KH

Go to Top of Page

siegblazer
Starting Member

5 Posts

Posted - 2007-06-21 : 01:24:12
o i trying to group the intRegistrationIdTR so that when display the table , it will be smth like this.


[url]http://img404.imageshack.us/img404/3673/tablefd1.jpg[/url]
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-21 : 01:35:02
This is not an issue with the GROUP BY in SQL but an presentation issue at the front and handled by the front end application.

Remove the GROUP BY, but add in ORDER BY


KH

Go to Top of Page

siegblazer
Starting Member

5 Posts

Posted - 2007-06-21 : 02:47:23
oic. u got msn? i got quite alot of questions i wan ask.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-06-21 : 02:50:12
email me yours from my profile


KH

Go to Top of Page
   

- Advertisement -