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 |
|
Swati Jain
Posting Yak Master
139 Posts |
Posted - 2006-09-29 : 09:08:02
|
| I have 2 tables parent tableis tlbForum with fields 'questioID'(primary key),'author' child table is tlbAnswer with field questionID(Foreign key),answerID(pk),namefrom that i want to select total answers submitted and other fieldsin the parent table (tlbForum)i tried as follows select count(tlbanswer.answerID),tlbforum.authorgroup by tlbanswer.fquestionIDwhere tlbForum.questionID=tlbanswer.questionIDbut it is not workingHow to make it correct?Swati Jain |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-09-29 : 09:12:25
|
| Select F.QuestionId,count(C.answers) from tblChild C inner join tblForum Fon C.questionId=F.questionIdMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-29 : 09:17:28
|
| GROUP BY must be written after WHERE.Peter LarssonHelsingborg, Sweden |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-09-29 : 09:24:21
|
| Also, your SELECT list can contain only those fields which are in GROUP BY or aggregations like count(), Sum() etc. In your case, you are grouping on fQuestionID but including author column in the SELECT list.Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|