How generate this SQL, with sqlalchemy
SELECT SUM(click) / SUM(impression) as my_indicator
FROM stats;
session.query(
func.sum(table.click).label("click"),
func.sum(table.impression).label("impression"),
# ??? sum(click) / sum(impression) ???
).group_by(table.type)
from sqlalchemy.sql import label
session.query(
label('my_indicator', sum(click) / sum(impression))
).group_by(table.type)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.