xxxxxxxxxx
if(cond, then, else)
SELECT if(1, plus(2, 2), plus(2, 6));
┌─plus(2, 2)─┐
│ 4 │
└───────────┘
SELECT
left,
right,
if(left < right, 'left is smaller than right', 'right is greater or equal than left') AS is_smaller
FROM LEFT_RIGHT
WHERE isNotNull(left) AND isNotNull(right)
┌─left─┬─right─┬─is_smaller──────────────────────┐
│ 1 │ 3 │ left is smaller than right │
│ 2 │ 2 │ right is greater or equal than left │
│ 3 │ 1 │ right is greater or equal than left │
└──────┴───────┴──────────────────────────────┘
xxxxxxxxxx
SELECT DISTINCT dso.id,
IF(dsa.id > 0, dsa.birth_date, dsqa.birth_date) as birth_date,
IF(JSON_VALUE(dso.data,'$.my_id.common_data.gender') = '', '0', JSON_VALUE(dsad.data,'$.my_id.common_data.gender')) as gender,
dso.created_at, dso.updated_at
FROM db_service_orders as dso