<code>SELECT e.external_account_id, e.trade_type, e.stock_code, e.name, e.stock_name, SUM(e.trade_price * e.trade_count) / SUM(e.trade_count) AS trade_price, SUM(e.trade_count) AS trade_count FROM ( SELECT a.id, a.external_account_id, a.internal_account_id, a.trade_price, a.trade_count, b.stock_code, b.trade_type, c.name as stock_name, d.name FROM trades a, orders b, stocks c, external_accounts d WHERE a.order_id = b.id AND b.stock_code = c.code AND a.external_account_id = 29 AND d.id = 29 ) AS e GROUP BY e.stock_code, e.trade_type</code>
这段sql转换成ORM应该怎么写啊= =。
Laravel用的不多,求高玩赐教。。
踩我的朋友们,嫌我问的问题low?问的low你来答啊。答不出来还踩,什么心态。?
<code>SELECT e.external_account_id, e.trade_type, e.stock_code, e.name, e.stock_name, SUM(e.trade_price * e.trade_count) / SUM(e.trade_count) AS trade_price, SUM(e.trade_count) AS trade_count FROM ( SELECT a.id, a.external_account_id, a.internal_account_id, a.trade_price, a.trade_count, b.stock_code, b.trade_type, c.name as stock_name, d.name FROM trades a, orders b, stocks c, external_accounts d WHERE a.order_id = b.id AND b.stock_code = c.code AND a.external_account_id = 29 AND d.id = 29 ) AS e GROUP BY e.stock_code, e.trade_type</code>
这段sql转换成ORM应该怎么写啊= =。
Laravel用的不多,求高玩赐教。。
踩我的朋友们,嫌我问的问题low?问的low你来答啊。答不出来还踩,什么心态。?
转换成ORM增加了复杂性,降低了sql语句可读性,还不如直接用DB::select()
来执行sql。
复杂的sql没必要改成orm