我对Sybase Query有以下要求: -
在下列情况下排除:
我写了如下的案例陈述,但它不起作用,请有人帮忙请:
SELECT CASE
WHEN LEN(a.MEMBER_SSN) > 9 THEN ' '
WHEN LEN(a.MEMBER_SSN) < 9 THEN ' '
WHEN LTRIM(RTRIM(a.MEMBER_SSN)) like '%[A-Z,a-z]%' then ' '
WHEN LTRIM(RTRIM(WHEN a.MEMBER_SSN)) like '%[0-9]%' then ' '
WHEN LTRIM(RTRIM(a.MEMBER_SSN)) in ( '000000000','000000001','000000002','000000003','000000004','000000005','999999999','111111111','000000070','123456789','999999998','000000071','888888888', ) THEN ''
WHEN LTRIM(RTRIM(a.MEMBER_SSN)) NOT LIKE '9__[789]%' THEN a.MEMBER_SSN ELSE ' '
WHEN LTRIM(RTRIM(a.MEMBER_SSN)) NOT LIKE '____[00]%' THEN a.MEMBER_SSN ELSE ' '
WHEN LTRIM(RTRIM(a.MEMBER_SSN)) NOT LIKE '_____[0000]%' THEN a.MEMBER_SSN ELSE ' '
END AS SUBSCRIBER_SSN From dbo.MEMBER_TABLE a
这是一个较短的版本:
SELECT (CASE WHEN LEN(a.MEMBER_SSN) <> 9 THEN ' '
WHEN a.MEMBER_SSN LIKE '%[^0-9]%' THEN ' '
WHEN REPLACE(a.MEMBER_SSN, LEFT(a.MEMBER_SSN, 1), '') = '' THEN ' '
WHEN a.MEMBER_SSN LIKE '9__[789]%' THEN ' '
WHEN a.MEMBER_SSN LIKE '___00%' AND a.MEMBER_SSN <> '800-00-0000' THEN ' '
WHEN a.MEMBER_SSN LIKE '%0000' THEN ' '
ELSE a.MEMBER_SSN
END) AS SUBSCRIBER_SSN
From dbo.MEMBER_TABLE a
这几乎是你的条件的直接转录。