can you help me to translate this sql query that correctly runs under my
mysql server?
SELECT * FROM (SELECT * FROM power_curve ORDER BY start DESC) AS TMP
GROUP BY site;
moreover.... if I execute:
db.executesql('SELECT * FROM (SELECT * FROM power_curve ORDER BY start
DESC) AS TMP GROUP BY site')
I obtain:
---------------------------------------------------------------------------
ProgrammingError Traceback (most recent call last)
/home/manuele/Dropbox/sviluppo/web2py-1.96.4/applications/wind2pow2/models/utils_lib.py
in <module>()
----> 1
2
3
4
5
/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/dal.pyc in
executesql(self, query, placeholders, as_dict)
4297 self._adapter.execute(query, placeholders)
4298 else:
-> 4299 self._adapter.execute(query)
4300 if as_dict:
4301 if not hasattr(self._adapter.cursor,'description'):
/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/dal.pyc in
execute(self, *a, **b)
1232
1233 def execute(self,*a,**b):
-> 1234 return self.log_execute(*a, **b)
1235
1236 def represent(self, obj, fieldtype):
/home/manuele/Dropbox/sviluppo/web2py-1.96.4/gluon/dal.pyc in
log_execute(self, *a, **b)
1227 self.db._lastsql = a[0]
1228 t0 = time.time()
-> 1229 ret = self.cursor.execute(*a,**b)
1230 self.db._timings.append((a[0],time.time()-t0))
1231 return ret
ProgrammingError: column "tmp.id" must appear in the GROUP BY clause or
be used in an aggregate function
LINE 1: SELECT * FROM (SELECT * FROM power_curve ORDER BY start DESC...
thankyou very mutch
Manuele