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

  • Home
  • SEARCH
  • 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 855193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:02:21+00:00 2026-05-15T08:02:21+00:00

Suppose I have data in table X: id assign team ———————- 1 hunkim A

  • 0

Suppose I have data in table X:

id     assign  team
 ----------------------  
 1     hunkim    A  
 1     ygg       A  
 2     hun       B  
 2     gw        B  
 2     david     B  
 3     haha      A

I want to know how many assigns for each id. I can get using:

select id, count(distinct assign) from
X group by id
order by count(distinct assign)desc;

It will give me something:

1  2
2  3
3  1

My question is how can I get the average of the all assign counts?

In addition, now I want to know the everage per team. So I want to get something like:

team    assign_avg
-------------------
A         1.5
B         3

Thanks in advance!

  • 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-05-15T08:02:22+00:00Added an answer on May 15, 2026 at 8:02 am
    SELECT
        AVG(CAST(assign_count AS DECIMAL(10, 4)))
    FROM
        (SELECT
            id,
            COUNT(DISTINCT assign) AS assign_count
        FROM
            X
        GROUP BY
            id) Assign_Counts
    

    .

    SELECT
        team,
        AVG(CAST(assign_count AS DECIMAL(10, 4)))
    FROM
        (SELECT
            id,
            team,
            COUNT(DISTINCT assign) AS assign_count
        FROM
            X
        GROUP BY
            id,
            team) Assign_Counts
    GROUP BY
        Team
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a table . Now, I'm interested in Getting Useful Data Easily.
Suppose I want entries in the table Regions to have a type, e.g. a
In MySQL, suppose I have a table called 'data' with columns 'x', 'y', and
Suppose I have a table view, and I want to implement something like this:
Suppose I have some per-class data: (AandB.h) class A { public: static Persister* getPersister();
Suppose I have a text file with data separated by whitespace into columns. I
Suppose we have a table A: itemid mark 1 5 2 3 and table
Suppose you have a table: CREATE TABLE Customer ( batch_id NUMBER, customer_name VARCHAR2(20), customer_address
Suppose I have a MySQL database named DB, and a table named ContactInfo. The
suppose i have a query $array = array(); $sql = mysql_query(SELECT * FROM table);

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.