如何在查询中添加count(id)

时间:2018-07-18 12:34:04

标签: python sqlalchemy flask-sqlalchemy

我想在sqlalchemy(烧瓶)中执行以下查询

df['bar'] = df['foo'].apply(lambda x: (int(x, 16) - int((int(x, 16) << 1) & 0x1000000)))
print (df)
        foo    bar
0  0xff49f1 -46607
1  0xff49f0 -46608

我有以下内容:

SELECT  b.id, 
        b.title, 
        COUNT(i.id)
FROM book b
LEFT JOIN invoice i
    ON b.id = i.book_id and settled=1
WHERE b.deleted=0
GROUP BY b.id;

查询运行正常,但我仍然缺少count(i.id)部分。

任何想法如何将其添加到查询中?

0 个答案:

没有答案