nashsaint Posted March 29, 2009 Share Posted March 29, 2009 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. Quote Link to comment Share on other sites More sharing options...
corbin Posted March 29, 2009 Share Posted March 29, 2009 SELECT a_month, COUNT(eid) as total FROM m_month GROUP BY a_month; Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2009 Share Posted March 29, 2009 And if your months were numerical, you could get the data in the correct order at the same time. Quote Link to comment Share on other sites More sharing options...
nashsaint Posted March 29, 2009 Author Share Posted March 29, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.