fix: 供应商排行JOIN organization.name获取orgname
This commit is contained in:
parent
aeb5950cd0
commit
8da46acbce
@ -247,9 +247,9 @@ async def get_top_models(env, sor, limit=5):
|
|||||||
async def get_top_providers(env, sor, limit=5):
|
async def get_top_providers(env, sor, limit=5):
|
||||||
"""Top N 供应商(按金额,全量)"""
|
"""Top N 供应商(按金额,全量)"""
|
||||||
sql = """SELECT f.providerid, COUNT(*) as cnt, COALESCE(SUM(f.amount_cny), 0) as total_amount,
|
sql = """SELECT f.providerid, COUNT(*) as cnt, COALESCE(SUM(f.amount_cny), 0) as total_amount,
|
||||||
COALESCE(p.name, f.providerid) as provider_name
|
COALESCE(o.name, f.providerid) as provider_name
|
||||||
FROM dm_model_call_fact f
|
FROM dm_model_call_fact f
|
||||||
LEFT JOIN modelprovider p ON p.id = f.providerid
|
LEFT JOIN organization o ON o.id = f.providerid
|
||||||
WHERE f.providerid IS NOT NULL
|
WHERE f.providerid IS NOT NULL
|
||||||
GROUP BY f.providerid ORDER BY total_amount DESC LIMIT ${limit}$"""
|
GROUP BY f.providerid ORDER BY total_amount DESC LIMIT ${limit}$"""
|
||||||
recs = await sor.sqlExe(sql, {'limit': limit})
|
recs = await sor.sqlExe(sql, {'limit': limit})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user