ID Realname SEX
1 10082 Pine XX
2 10084 Lam xx 1
3 10087 West XX
4 10100 hu xx
5 10102 Dragon xx 1
Usage ============
Select U.id,u.realname,
(Case U.sex
When 1 Then ' Male '
When 2 Then
Female
Else ' empty '
END
) gender
from Users u;
====
In the second case, if the a field is not empty, use the A field, or the B field if it is empty
Select T.epvd_name, T.ff, Count (t.epod_id) from (
Select Epv.epvd_name, Case when To_char (Epod.epod_create_time, ' yyyymm ') are NULL then To_char (Epod.epod_update_time, ' Yyyymm ') ELSE to_char (epod.epod_create_time, ' yyyymm ') END FF, epod.epod_id
From Ep_order_detail ePOD
Left join Ep_vendor epv on epv.epvd_id = epod.vendor_id
where Epod.epod_status > 0
and Epv.epvd_status=1) t
Group BY T.epvd_name, T.ff
ORDER BY T.ff
Note: Aliases cannot be used in this order;
The usage and similar usage of Oracle case time is to use a field if the A field is not empty, and B field if empty