test

Sql code posted
created at 06 Jun 09:45

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
SELECT COUNT(*) AS valid_records_count
FROM (
    SELECT *,
        CASE WHEN ${phone} RLIKE '^(?:(?:\+|00)86)?1[3-9]\\d{9}$' THEN 1 ELSE 0 END AS phone_valid_count,
        CASE WHEN ${id_number} RLIKE '^[1-9]\\d{5}(?:18|19|20)\\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\\d|30|31)\\d{3}[\\dXx]$' THEN 1 ELSE 0 END AS id_number_valid_count,
        CASE WHEN ${email} RLIKE '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$' THEN 1 ELSE 0 END AS email_valid_count
    FROM ${table}
    WHERE 
    ${cust_type} = 1 and  ${partition})
subquery
WHERE (phone_valid_count + email_valid_count + id_number_valid_count) >= 2;
625 Bytes in 2 ms with coderay