How should I write the SQL statement {code...} into an ORM. Laravel is not used much. Please give me some advice .. If I step on my friends, what is the question I asked? You can answer the question. What kind of mentality can't I answer .?
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
How should I write this SQL statement into an ORM? =.
Laravel is not used much. Please give me some advice ..
If I step on my friends, what is the question I asked? You can answer the question. What kind of mentality can't I answer .?
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
How should I write this SQL statement into an ORM? =.
Laravel is not used much. Please give me some advice ..
If I step on my friends, what is the question I asked? You can answer the question. What kind of mentality can't I answer .?
Converting to An ORM increases complexity and reduces the readability of SQL statements.DB::select()To execute SQL.
Complex SQL statements do not need to be changed to orm.