Finding accounts

Hi all,

I was wondering if anyone has any SQL script written to be able to find household accounts that only have one individual account. We are realizing we seem to have a lot of accounts like this and want to clean our date. I couldn't think of an easy way to pull a list to find this data so I thought I'd reach out and see if anyone wrote a script in SQL to do this.

Any and all help and advice is greatly appreciated.

Chris Cuhel

The 5th Avenue Theatre

Parents
  • Unknown said:

    I was wondering if anyone has any SQL script written to be able to find household accounts that only have one individual account. 

    This should work:


    select af.group_customer_no,count(*)
    from T_AFFILIATION af
    join T_CUSTOMER cu
    on af.group_customer_no = cu.customer_no and cu.cust_type = 7
    group by af.group_customer_no
    having count(*) = 1

Reply
  • Unknown said:

    I was wondering if anyone has any SQL script written to be able to find household accounts that only have one individual account. 

    This should work:


    select af.group_customer_no,count(*)
    from T_AFFILIATION af
    join T_CUSTOMER cu
    on af.group_customer_no = cu.customer_no and cu.cust_type = 7
    group by af.group_customer_no
    having count(*) = 1

Children