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_countFROM ( 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 eGROUP BY e.stock_code, e.trade_type
This SQL conversion to ORM should be how to write ah = =.
Laravel use not much, ask high play enlighten.
Step on my friends, I ask the question of low? Ask the low you come to answer AH. Do not come out also tread, what mentality.?
Reply content:
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_countFROM ( 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 eGROUP BY e.stock_code, e.trade_type
This SQL conversion to ORM should be how to write ah = =.
Laravel use not much, ask high play enlighten.
Step on my friends, I ask the question of low? Ask the low you come to answer AH. Do not come out also tread, what mentality.?
Converting to ORM adds complexity and reduces the readability of SQL statements, rather than directly DB::select()
executing SQL.
Complex SQL doesn't need to be an ORM.