27 lines
572 B
Plaintext
27 lines
572 B
Plaintext
ns = params_kw.copy()
|
|
|
|
sql = """select a.*, b.name as miname, c.name as mtname,
|
|
concat(b.name, '(', c.name, ')') as name
|
|
from
|
|
(select modelinstanceid as mii,
|
|
modeltypeid as mti,
|
|
avg(estimate) as estimate
|
|
from feelog
|
|
where transdate >= ${start_date}$ and
|
|
transdate < ${end_date}$ and
|
|
finish_time is not null
|
|
group by mii, mti
|
|
) a,
|
|
modelinstance b,
|
|
modeltype as c
|
|
where a.mii = b.id and
|
|
a.mti = c.id
|
|
order by estimate
|
|
limit 5
|
|
"""
|
|
db = DBPools()
|
|
async with db.sqlorContext('sage') as sor:
|
|
recs = await sor.sqlExe(sql, ns.copy())
|
|
return recs
|
|
return []
|