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.

The resulting sql should give one row for every 3-month period as
defined by the Date field. I don't get all the groups.

If I group by Date instead of my calculated period, I see one row for
every unique date as expected.

Then, I switch the GROUP BY back to Period. The first try results in
three resultant rows, a null one (for null dates) Jan-Mar 1999 and
Jan-Mar 2000.

I run it again - no change - and get a fourth row the second and
subsequent times, Oct-Dec 1999.

Any idea what's going on?

Jamie



---------------------------------------------------------------------
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