Quantcast
Channel: Join two tables and return data and count in a single query - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 3

Join two tables and return data and count in a single query

$
0
0

I have two tables in an SQL Server database, one with two columns and one with four:

  1. tbl_email_list

    1. email_list_idint (PK)
    2. email_list_namevarchar
  2. tbl_email-details

    1. email_uniq_idint (PK)
    2. email_list_idint (FK)
    3. email_addressvarchar
    4. blacklistbit

I want to retrieve data in one query which should return

  1. All the email lists from tbl_email_list;
  2. The total number of email_address associated with a specific email_list_id;
  3. The total number of whitelisted email addresses (where blacklist=0);
  4. The total number of blacklisted email addresses (where blacklist=1).

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images