node.js - I tried writing sequelize query for sql query, but I am getting error as In aggregated query without GROUP BY -
the sql query is:
select mf_status, count(distinct(mp_orders.id)) mp_orders left join mp_order_status_map on mporderstatus = mp_order_status left join mf_order_status on mf_order_statusid = mf_order_status.id group mf_status;
sequelize written is:
return orders.findall({attributes:[[sequelize.fn('count', sequelize.fn('distinct','id')), 'orders']], : querywhere, raw: true, include:[{ model:mporderstatusmap, attributes:[], on:{"mp_order_status":{"$col":"mporderstatus"}}, include:[{ model:mforderstatus, on:{"id":{"$col":"mf_order_statusid"}}, attributes: [[sequelize.col('mf_status'), 'status']], raw: true, group: [sequelize.col('mf_status')] }] }] });
error got:
error: in aggregated query without group by, expression #2 of select list contains nonaggregated column 'mf.mporderstatusmap->mforderstatus.id'; incompatible sql_mode=only_full_group_by
wiki
Comments
Post a Comment