J'ai la table pyDAL suivante:Création d'un HAVING COUNT (colonne)> 2 clause pyDAL
market = db.define_table(
'market',
Field('name'),
Field('ask', type='double'),
Field('timestamp', type='datetime', default=datetime.now)
)
Je voudrais utiliser la langue d'expression pour exécuter l'instruction SQL suivante:
SELECT * FROM market
GROUP BY name
ORDER BY timestamp DESCENDING
HAVING COUNT(name) > 1
Je sais comment faire le ORDER BY
et GROUP BY
:
db().select(
db.market.ALL,
orderby=~db.market.timestamp,
groupby=db.market.name
)
mais je ne sais pas comment faire un compter dans une clause having même après avoir lu the section in the web2py book on the HAVING
clause.