Jump to content

SQL SELECT count by month


nashsaint

Recommended Posts

Hi,

 

Below is my sql query.

 

$query_JanCount = "SELECT count(eid) as TOTAL, a_month FROM m_month WHERE a_month = 'January'";

 

I have a table that will output the count result of the query.

 

I wanted to do same query for the other 11 months changing the WHERE clause but then i think that would be too heavy for sql to handle.  Is there a more optimized way of doing this? say, function maybe?  or an array? I don't have any idea how to code it. 

 

Any help is greatly appreciated.

Link to comment
Share on other sites

thanks a lot for your help. it worked but i have another problem. sorry if i didn't mention it beforehand.

 

This is how i'm hoping the result would look like:

Firstname

january

february

result -->

Mark

121

234

result -->

Anthony

4324

234

 

and if i group it by month it produced a different result.  I tried grouping it in Firstname but now the count result counts everything from the database and doesn't separate by month.

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.