Click to See Complete Forum and Search --> : group by date, and combine sat and sun with monday


nemesis_256
11-10-2009, 11:25 AM
I'm not sure if this is possible. I'm creating a contest platform, and people will be entering every day, but prizes are only given away during week days. Now I'm building an admin so someone will randomly pick a winner for each day. In the admin I do not want Saturdays and Sundays to show up, but I want the number of people who entered on those days to show up on Monday.

Here's my current query:
select dateAdded, count(option1) as option1, count(option2) as option2, count(option3) as option3, count(option1) + count(option2) + count(option3) as total, group_concat(winner separator '|') as winner from users group by dateAdded order by dateAdded desc

People will have 3 ways to enter, so that's what the option1 through 3 columns are. The group_concat is for the possibility of having multiple winners per day, to display them.

Now with "gorup by dateAdded", Saturday and Sundays would be their own days. How can I combine them into one row with the data from Monday?

ssystems
11-11-2009, 03:15 PM
Would be better if you can give as a snip of your table structures.

Shorts
11-11-2009, 06:54 PM
try a GROUP BY day

and in the select have something like, weekday_boolean being your boolean to decide if it's a weekday or not
IF(weekday_boolean,day,'monday') AS day