CASE WHEN (D.BUYQ>0 AND D.SELLQ>0 AND D.series_expiry='2050-01-01') then
sum(D.stt_INTRA_buy*least(D.buyq,D.SELLQ)*D.buyavg)+sum(D.stt_buy*(D.buyq-least(D.buyq,D.SELLQ))*D.buyavg)
ELSE
sum(D.stt_bu
新手需要一點幫助。有人可以提供一個查詢,以方便地讀,然後按月記錄匹配的兩個條件製表避免使用笨拙的重複這樣的代碼...... SELECT
SUM(CASE
WHEN extract(YEAR FROM `date`) = "2017"
AND extract(MONTH FROM `date`) = "07"
AND `conditionA` = "A"
我有一個正確的MySQL查詢,但我真的很困惑,將此轉換爲CI。 我要的結果就是這樣 query result select sum(distinct(tns.nilai)),tns.nis
from trs_nilai_sikap tns inner join trs_riwayat_nilai_sikap trns
on trns.id_tahun_ajar = 2
and tns.nis