![]() |
|
#1
|
|||
|
|||
SubqueryI need the get a rolling 30 day average, so for each day I need to get a average of the 30 days before it. The following works in Microsoft Access, but I can't get it to work with MySQL and PHP, any ideas:
SELECT tbldailydatal1.Date, Avg(tbldailydatal1_1.MetalTap/tbldailydatal1_1.Pots) AS 30DayPPD FROM tbldailydatal1, tbldailydatal1 AS tbldailydatal1_1 WHERE (((tbldailydatal1_1.Date) Between DateAdd("d",-30,[tbldailydatal1].[Date]) And [tbldailydatal1].[Date])) GROUP BY tbldailydatal1.Date HAVING (((tbldailydatal1.Date) Between #9/1/2004# And #1/25/2005#)); Any suggestions? |
|
#2
|
|||
|
|||
|
Isn't DateAdd() a specific Access function?
|
|
#3
|
|||
|
|||
|
I'm referencing a file that creates a DateAdd funtion for MySQL. The following works when I take of the "Having" clause, but I need to limit the data to a specific date range, any suggestions?
$SQLstatement = "Select UNIX_TimeStamp(t1.Date), Avg(t2.MetalTap/t2.Pots) AS DayPPD From tbldailydatal1 as t1, tbldailydatal1 as t2 WHERE t2.Date between 'DateAdd(d,-30,t1.Date)' and t1.Date GROUP BY t1.Date HAVING t1.Date Between '$Selectedstart' and '$Selectedend'"; |
Recent GIDBlog
Prepping for deployment by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The