dimanche 7 mars 2021

Case statement in multiple conditions?

I want to check the column mr.name, if mr.name is null then i have to replace mr.name as mr.ticket_no. How? Whether I can use if else or case ? Please suggest me

    select ROW_NUMBER() OVER(ORDER BY mr_user) sl_no,* from (select 
    mr.name as mr_no,
    coalesce(mr.user_id,0) as mr_user
    from stock_production_lot lot
    left join kg_grn grn on (grn.name = lot.grn_no)
    left join kg_department_indent mr on (mr.name = grn.mr_no)
    order by mr.user_id) main
    where  mr_user=65

When i use like this case when mr.name is null then '' else mr.ticket_no = grn.mr_no as mr_no it will throw error

if mr.name = null means i have to replace mr.name = mr.ticket_no. I want to check the column mr.name, if mr.name is null then i have to replace mr.name as mr.ticket_no How ? Whether we can use if else or case ? Please suggest me

Aucun commentaire:

Enregistrer un commentaire