Jump to content

Recommended Posts

is it possible to do a multiple group query such as below

I get all returned in one group with different fund accounts and projects no group is made?

 

SELECT sum(amount), bank_account, fund, account, project FROM sc_allocated_funds WHERE expense_id IS NOT NULL GROUP BY fund AND account AND project

Link to comment
https://forums.phpfreaks.com/topic/186794-multiple-group-query/
Share on other sites

It all depends on the structure of the data, but I think your GROUP BY is flawed, not sure if AND is valid syntax?

 

GROUP BY fund, account, project

 

I think commas need to be used. I am not 100% sure on that but yea. If there is a unique field being returned then the group by will not work. Such as the primary key etc. If the all the items are not unique then it should work and group them.

Link to comment
https://forums.phpfreaks.com/topic/186794-multiple-group-query/#findComment-986624
Share on other sites

ok my mistake

 

i changed sum(amount) to amount in the 1st part and it only showed the 1st line out of 8

 

SELECT amount, bank_account, fund, account, project FROM sc_allocated_funds WHERE expense_id IS NOT NULL GROUP BY fund , account , project

 

when I changed it back to sum(amount) it worked, maybe when i did it the other day manually i hit a wrong digit as myphp admin sql is small even on my 28 in monitor

 

SELECT sum(amount), bank_account, fund, account, project FROM sc_allocated_funds WHERE expense_id IS NOT NULL GROUP BY fund , account , project

 

much thanks for the help the AND was wrong and the comma was right!

Link to comment
https://forums.phpfreaks.com/topic/186794-multiple-group-query/#findComment-986790
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.