Simple WITH clause

WITH AS (subquery)
SELECT FROM [,table]

WITH clause with multiple subqueries

WITH AS (subquery)
, AS (subquery)
SELECT FROM , [, table]
[ WHERE ]

for example find duplicate phone number rows in customer

now more complex. the following statement converts the DAY_PHONE field to only numbers and only the first 10 digits and then checks for duplicate records

OnlyNumbers is a stored procedure that returns only the numbers from a string

next same as above but check multiple fields for duplicates