List:General Discussion« Previous MessageNext Message »
From:Brent Baisley Date:August 14 2006 12:42pm
Subject:Re: Group by with an IF
View as plain text  
The problem is your GROUP BY on celec_id. MySQL is doing the grouping and thus only
grabbing the first season_week_date value within 
the grouping. I'm not sure what end result your are looking for. Grouping additionally by
season_week_date might be what you are 
looking for.
GROUP BY r.celeb_id, season_week_date

----- Original Message ----- 
From: "Steffan A. Cline" <steffan@stripped>
To: <mysql@stripped>
Sent: Sunday, August 13, 2006 5:33 AM
Subject: Group by with an IF


>I have the following query:
>
> select *,
> if( season_week_date = "2006-08-16", "on", "off" ) as stat,
> sum(overall_points) as total_points
> from rosters r
> left join celebs c
> on c.celeb_id = r.celeb_id
> where
> season_id=5062
> and user_id=1
> group by r.celeb_id
> order by overall_rank, ln, fn;
>
> It almost works as expected however the problem I am concerned about is that
> I never get a stat saying "On" after it resolves. Removing the sum() and
> adding group I get the total_points as expected but now the results are
> always off.
>
> Can anyone shed any light on this one?
>
>
> Thanks
>
> Steffan
>
> ---------------------------------------------------------------
> T E L  6 0 2 . 5 7 9 . 4 2 3 0 | F A X  6 0 2 . 9 7 1 . 1 6 9 4
> Steffan A. Cline
> Steffan@stripped                             Phoenix, Az
> http://www.ExecuChoice.net                                  USA
> AIM : SteffanC          ICQ : 57234309
>                                  Lasso Partner Alliance Member
> ---------------------------------------------------------------
>
>
>
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
> 

Thread
Group by with an IFSteffan A. Cline13 Aug
  • loggingJosh Milane13 Aug
  • Re: Group by with an IFChris14 Aug
  • Re: Group by with an IFBrent Baisley14 Aug