|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
SQL group by
Two tables: tableTournament, tablePlayerDetails
In tableTournament are, among other fields, intPlayerID, intRanking and intMoney. For each tournament a player gets ranking points and money. In tablePlayers I've got strPfirstname and strPsurname. I want to create a ranking list that aggregates intRanking and intMoney and shows the playername. I've tested the following but it does not work: SQLrank = "SELECT tableTournament.intPlayerID,SUM(tableTournament.in tRanking), SUM(tableTournament.intMoney)," & _ "tablePlayerDetails.strPfirstname,tablePlayerDetail s.strPsurname FROM tableTournament,tablePlayerdetails " & _ "GROUP BY tableTournament.intPlayerID HAVING tableTournament.intPlayerID=tablePlayerDetails.Pla yerID ORDER BY tableTournament.intRanking DESC" Error message: Microsoft JET Database Engine error '80040e21' You tried to execute a query that does not include the specified expression 'strPfirstname' as part of an aggregate function. Any ideas? |
|
#2
|
|||
|
|||
|
Hi,
Try this: - Code:
SELECT tableTournament.intPlayerID, tablePlayerdetails.strPfirstname, tablePlayerdetails.strPsurname, Sum(tableTournament.IntRanking) AS SomVanIntRanking, Sum(tableTournament.intMoney) AS SomVanintMoney FROM tableTournament HAVING tableTournament.intPlayerID = tablePlayerdetails.IntPlayerID GROUP BY tableTournament.intPlayerID, tablePlayerdetails.strPfirstname, tablePlayerdetails.strPsurname, tableTournament.IntRanking ORDER BY tableTournament.IntRanking DESC; Regards, Michiel |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > SQL group by |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|