CONCAT():
mysql> SELECT CONCAT(’My’, ‘S’, ‘QL’);
-> ‘MySQL’
IF():
IF(expr1,expr2,expr3)
select *,if(sva=1,"男","女") as ssva from taname where sva != ""
作为表达式的if也可以用CASE when来实现:
select CASE sva WHEN 1 THEN '男' ELSE '女' END as ssva from taname where sva != ''
查询差异样例, 查询A表和B表的ACCOUNT_ID列数据是否一致,不一致的标记为N并筛选出来
select * from
(select a.ACCOUNT_UID, a.ACCOUNT_ID as A, b.ACCOUNT_ID as B, iff(a.ACCOUNT_ID=b.ACCOUNT_ID, 'Y', 'N')as result
from QA_PREDEV.DW_CENTRAL."DIM_ACCOUNT" a join RPT_DW_PREDEV.DW_CENTRAL."DIM_ACCOUNT" b
on a.ACCOUNT_UID = b.ACCOUNT_UID and a.RECORD_START_DATE=b.RECORD_START_DATE and a.RECORD_END_DATE) test where test.result = 'N';