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?
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.