Jump to content

Recommended Posts

Hey all,

 

I've got a table with the following columns:

DATE EVENT COUNT FAIL

 

it basically keeps a track of how many times an even occurs/fails on a day, and there can be multiple events (A, B, C).

 

1-july A 20 34

1-july B 27 46

1-july C 26 23

2-july A 24 09

2-july B 22 19

3-july C 21 10

 

I wanted to write a query to give me the total sum of COUNT and FAIL for EVEN A for july-1 to july-3, I cant seem to figure out how to get MySQL to do this.

 

I know we can get all of the rows for event A with something like:

 

SELECT COUNT, FAIL from tbl WHERE DATE BETWEEN start AND end

 

but how can we get MySQL to group together all the columns with the same EVENT field and sum up their COUNT and FAIL columns?

Is this even possible with a single query? Any help is appreciated.

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/58820-solved-mysql-grouping-and-summing/
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.