SELECT brand_id, brand_name_en, brand_name_tcBy using the script can get the data shown below:
FROM db2_prod.tbl_brand
And my duty is to conbine 2 columns into one column,
the condition is there is if no any value in field "brand_name_tc", show the value in "brand_name_en".
(If there is any Chinese brand name, show chinese name; if no chinese name, show english barnd name)
And finally i have used "CASE expression":
SELECT brand_id,
Case when brand_name_tc=' ' then brand_name_en
when brand_name_tc !=' ' then brand_name_tc
else 'nothing'
End as brand_name
FROM db2_prod.tbl_brand;
And get
No comments :
Post a Comment