Home > Enterprise >  Generating unique contact % with sql
Generating unique contact % with sql

Time:08-13

I am hoping to generate unique contact %. not sure how to divide the 2. Can someone help? thanks

select
attached to_,
count(record),
count(distinct customer),
from table
group by 1

table of sample data enter image description here

CodePudding user response:

Try the following:

Select attached_to,
       COUNT(customer) As total_contact,
       COUNT(Distinct customer) As unique_contact,
       COUNT(Distinct customer) / COUNT(customer) As '%_of_unique'
From Tbl
Group By attached_to

See a demo from db<>fiddle.

  •  Tags:  
  • sql
  • Related