你好朋友我有這個查詢使用sql編輯器運行,但我不知道如何使用laravel.please編寫這個查詢幫助我。如何在laravel中編寫sql查詢
SELECT
date,
memo,
(COALESCE(CASE WHEN drcr = 'dr' THEN amount END,0)) total_debits,
(COALESCE(CASE WHEN drcr = 'cr' THEN amount END,0)) total_credits,
@b := @b + (COALESCE(CASE WHEN drcr = 'cr' THEN amount END,0)) - (COALESCE(CASE WHEN drcr = 'dr' THEN amount END,0)) balance
FROM
(SELECT @b := 0.0) AS dummy
CROSS JOIN
tbl_bankrecords
ORDER BY
date
你好亞洲時報Siddharth如何添加此part.will請你ellaborate it.FROM (SELECT @b:= 0.0)作爲虛擬 CROSS JOIN tbl_bankrecords ORDER BY 日期 – akash
只是儘量把所有你所提到的事情'Model :: select(DB :: raw('把你的原始查詢放在這裏')) - > get();'。我不確定,但這應該起作用 – Siddharth