sql - Finding Count of Duplicate emails that has a different first and/or last name -
hi i'm having trouble getting right count problem. i'm trying count of duplicate email has different first name and/or different last name. (i.e 123@.com sam 123@.com ben need count of duplicate email) i'm working 2 tables. email_address in mrtcustomer.customer_email table , first , last name in mrtcustomer.customer_master table
my code
select count(*) (select e.customer_master_id, email_address, customer_first_name, customer_last_name, row_number() on (partition email_address order customer_first_name) rn mrtcustomer.customer_email e join mrtcustomer.customer_master t on e.customer_master_id = t.customer_master_id t.customer_first_name not null , t.customer_last_name not null , customer_first_name != 'unknown' , customer_last_name != 'unknown' group e.customer_master_id, email_address, customer_first_name, customer_last_name order 1 desc) rn > 1
i'm guessing clause wrong.
i start this: (edited reflect edits)
select email_address , count( distinct customer_first_name ) f , count( distinct customer_last_name ) l customer_email e, customar_master m e.customer_master_id = m.customer_master_id group email_address
then if either of name columns > 1 have problem - wrap similar this:
select email_address ( select email_address , count( distinct customer_first_name ) f , count( distinct customer_last_name ) l customer_email e, customar_master m e.customer_master_id = m.customer_master_id group email_address ) fn > 1 or ln > 1
Comments
Post a Comment