not sure about the web2py translation (that would take me some time to 
figure out since i have not done much grouping in web2py), but:

SELECT * FROM (SELECT * FROM power_curve ORDER BY start DESC) AS TMP 
GROUP BY site;

is not valid.  i'm surprised that it works on mysql server.  every column 
that appears in the select must be aggregated or part of the group by clause 
for the query to be valid.

based on a counting query i have done in the past:

start_max = db.curve.start.max()
db((db.curve.site==db.site.id)).select(start_max, db.site.id, 
groupby=db.site.id)

does that work, or at least get you started?

cfh

Reply via email to