举例:
SELECT (@i:=@i+1) AS PM,A.*,
U.TNAME,
U.ID_NUM,
U.ORG_NAME,
CASE WHEN U.SEXFLAG=1 THEN '男' WHEN U.SEXFLAG=2 THEN '女' ELSE '' END SEX,
CASE WHEN LENGTH(ID_NUM) = 18 THEN YEAR(NOW()) - CAST(SUBSTRING(ID_NUM, 7, 4) AS SIGNED) ELSE '' END AS AGE
FROM TB_GH_MARATHON A
LEFT JOIN TB_GH_USER U ON A.USER_ID = U.USER_ID
,(SELECT @i:=0) t
WHERE 1=1 AND A.STATE = '1'
加上红色字体的代码即可
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。