Ich habe Fehler in MySQL-Abfrage, so brauche ich eine if-Anweisung basierend auf dem vorherigen Wert auswählen.CASE in Select-Anweisung MySQL
hier ist meine Frage,
SELECT
ds.master_rcpt_gen,
ds.visa_rcpt_gen,
dsp.curr_amount,
dsp.curr_id,
mcr.conv_rate,
mcr.curr_code,
mcr.curr_desc,
mcr.curr_type,
(conv_rate/(select mcr.conv_rate from mst_currencies_rate mcr where mcr.curr_code = 'USD')) conv_ratio,
curr_amount * (conv_rate/(select mcr.conv_rate from mst_currencies_rate mcr where mcr.curr_code = 'USD')) conv_usd,
(select mtr.USD_tax_rate from mst_tax_rate mtr) * (curr_amount * (conv_rate/(select mcr.conv_rate from mst_currencies_rate mcr where mcr.curr_code = 'USD'))) AS conv_taxrate_commission,
CASE WHEN mcr.curr_type = 'LOCAL' THEN conv_taxrate_commission = dsp.curr_amount ELSE (select mtr.USD_tax_rate from mst_tax_rate mtr) * (curr_amount * (conv_rate/(select mcr.conv_rate from mst_currencies_rate mcr where mcr.curr_code = 'USD')))
END final_conv_rate
FROM
dtl_sr ds
INNER JOIN dtl_sr_payment dsp ON dsp.flight_id = ds.flight_id
AND dsp.sr_id = ds.SR_ID
INNER JOIN mst_currencies_rate mcr ON mcr.curr_id = dsp.curr_id
passiert Mein Fehler in case-Anweisung, i die Case-Anweisung brauchen Wert von conv_taxrate_commission zu lesen. IF mcr.curr_type = 'LOCAL' muss conv_taxrate_commission gleich dsp.curr_amount sein, sonst muss ich die conv_taxrate_commission unverändert lassen.
Bitte helfen Sie mir
Welche Fehler Sie bekommen? –
Fehler 1054 unbekannte Spalte 'conv_taxrate_commission' in 'field_list' –
Warum 'conv_taxrate_commission = dsp.curr_amount' nach' THEN' in 'CASE' Ausdruck ?? – Wanderer