Jump to content

[SOLVED] How to mix group colums with no groups colum?


JJohnsenDK

Recommended Posts

Hey

how do i mix group colums with no group colums?

I have this:

[code]
$sql_actions = "SELECT SUM(a.goal) AS goals, COUNT(a.game_ID) as games, SUM(a.yellow_card) AS yellow, SUM(a.red_card) AS red, SUM(a.mins) AS mins, a.season_ID
FROM actions AS a
WHERE players_ID = ".$_GET['id']."";
[/code]

And get this error:

[i]Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause[/i]

I tried GROUP BY 1 but gets this error:

[i]Can't group on 'goals'[/i]

Anyone who can figure this out?
you had "AS a " in the wrong spot...

[code]$sql_actions = "SELECT SUM(a.goal) AS goals, COUNT(a.game_ID) as games, SUM(a.yellow_card) AS yellow, SUM(a.red_card) AS red, SUM(a.mins) AS mins, a.season_ID AS a FROM actions WHERE `players_ID`='$_GET[id]';[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.