Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7773439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:08:08+00:00 2026-06-01T17:08:08+00:00

I am very new to sql.I need some help in generating summery information MemberTable

  • 0

I am very new to sql.I need some help in generating summery information

MemberTable

MonthID  | UserID  | TeamID
-----------------------------
  1      |  1       | 1
  1      |  2       | 1
  1      |  3       | 1
  1      |  4       | 1
  1      |  5       | 2
  1      |  6       | 2
  1      |  7       | 2
  

AND

ReportTable

ID* |  MonthID  | UserID  | IsSend
-----------------------------------
 1  |    1      |    2     | False
 2  |    1      |    3     | True
 3  |    1      |    5     | True

I want to generate a summery like the following

TeamID     |  Total Count  |  Send Count | Not Send Count
-----------------------------------------------------------
 1         |      4        |      1      |     3
 2         |      3        |      1      |     2

Total Count : No of users in a team

Send Count : Total User in a team with IsSend = True

Not Send Count : Total Count – Send Count

What would be the efficent way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:08:08+00:00Added an answer on June 1, 2026 at 5:08 pm
    select MT.TeamID,
           count(distinct MT.UserID) as "Total Count",
           count(distinct case when RT.IsSend = 1 then MT.UserID end) as "Send Count",
           count(distinct MT.UserID) - count(distinct case when RT.IsSend = 1 then MT.UserID end) as "Not Send Count"
    from MemberTable as MT
      left outer join ReportTable as RT
        on MT.MonthID = RT.MonthID and
           MT.UserID = RT.UserID
    group by MT.TeamID
    

    Result:

    TeamID      Total Count Send Count  Not Send Count
    ----------- ----------- ----------- --------------
    1           4           1           3
    2           3           1           2
    

    Try here: https://data.stackexchange.com/stackoverflow/query/66347

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to sql.The actual problem is much bigger. I need information
Im very new to SQL but need to write a query to do the
I am very new to SQL and i need to retreive a number of
Hi I'm very new to sql but have been passed a job in which
I'm very new to Sql, and having trouble wrapping my brain around the syntax.
I am very new to using SQL and I haven't been able to find
I am a very experienced MS Sql developer, and a few new job positions
Very new to XSL (and XML for that matter), but I need to step
I am in a strange situation now, I am very new to MS Sql
probably a very simple answer but i'm new to T-SQL so could do with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.