By the way, if I rewrite the SQL without calculated fields, e.g.
instead of defining @MyYear, @StartMonth, and @EndMonth as variables
but rather duplicating the SQL to create a MyYear (and the others) column
and then inside the larger formula for Period, it works.

-- Jamie

The following statement:

SELECT Date, @MyYear := year(Date) AS MyYear, @StartMonth := 
floor((month(date)-1)/3)*3+1 AS StartMonth,
@EndMonth := floor((month(date)-1)/3)*3+3 AS EndMonth,
@Period := 
concat(left(monthname(concat('1-',@StartMonth,'-2000')),3),'-',left(monthname(concat('1-',@EndMonth,'-2000')),3),'
 ',year(date)) AS Period,
@Pgroup := CONCAT(@MyYear,@StartMonth,@EndMonth),
Avg(Operator_Courtesy) AS Courtesy,
avg(Operator_Knowledge) AS Knowledge,
avg(Operator_Etiquette) AS Etiquette,
avg(Overall_Impression) AS Overall FROM tbl_PhoneTester GROUP BY Period

gives incorrent and inconsistent results.  Server 3.23.31.

...



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to