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 8413303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:53:41+00:00 2026-06-10T00:53:41+00:00

I used to ask this question in this SO and already got the solution,

  • 0

I used to ask this question in this SO and already got the solution, however, that sql query produced only partial correct result. I have tried to figure it out but it seem to complicate for me to understand. So would you please kindly help me. Thank you.

for table tbl_sActivity

   act_id| Client_id | act_status| user_id | act_date 
    1    |      7    |    warm   |     1   | 19/7/12 
    2    |      7    |    dealed |     1   | 30/7/12 <- lastest status of client(7)          
    3    |      8    |    hot    |     1   | 6/8/12  <- lastest status of client(8)
    4    |      5    |    cold   |    22   | 7/8/12  <- lastest status of client(5)
    5    |      6    |    cold   |     1   | 16/7/12
    6    |      6    |    warm   |     1   | 18/7/12
    7    |      6    |    dealed |     1   | 7/8/12  <- lastest status of client(6)   
    8    |      9    |    warm   |    26   | 2/8/12
    9    |     10    |    warm   |    26   | 2/8/12  
    10   |      9    |    hot    |    26   | 4/8/12  <- lastest status of client(9)
    11   |     10    |    hot    |    26   | 4/8/12
    12   |     10    |    dealed |    26   | 10/8/12 <- lastest status of client(10)
    13   |     13    |    dealed |    26   | 8/8/12  <- lastest status of client(13)
    14   |     11    |    hot    |    25   | 8/8/12
    15   |     11    |    dealed |    25   | 14/8/12 <- lastest status of client(11)

I want to produce the User Progressive Report that shows the latest progress of how each user follow up his/her clients.
Therefore this report must show number of each user’s clients group by each of their latest status.

The correct output should be looked like this..

user_id | act_status | Count(act_status)
1       |   dealed   |    2
1       |    hot     |    1
22      |    cold    |    1 
25      |   dealed   |    1
26      |    hot     |    1
26      |   dealed   |    2

The SQL query that I had is below:

select user_id, act_status, count(act_Status)
from your_table
where act_date in (
    select  max(act_date)
    from your_table
    group by Client_id
)
group by user_id, act_status

which when i add more transactions to the database, the output went wrong like this..

user_id | act_status | Count(act_status)
1       |   dealed   |    2
1       |    hot     |    1
22      |    cold    |    1
25      |    hot     |    1 ** (this one shouldn't show up)
25      |   dealed   |    1
26      |    hot     |    2 ** (should be only '1')
26      |   dealed   |    2
  • 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-10T00:53:43+00:00Added an answer on June 10, 2026 at 12:53 am

    Tried and tested:

    SELECT S.user_id, S.act_status, Count(S.act_status) AS CountOfact_status
    FROM tbl_sActivity AS S INNER JOIN [SELECT A.client_id, Max(A.act_date) AS max_act
    FROM tbl_sActivity AS A
    GROUP BY A.client_id]. AS S2 ON (S.act_date = S2.max_act) AND (S.client_id = S2.client_id)
    GROUP BY S.user_id, S.act_status
    

    A similar request to an answer I gave yesterday, please try and read through my query as well as just using it, this will hopefully help you understand and is the only way to learn : )

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

Sidebar

Related Questions

i used this code: List<string> lists=new List<string>(apple,orange,banana,apple,mang0,orange); string names; names=lists.Distinct() is that correct?
I ask this question because I've implemented a javascript solution to nested inlines (it
First: I'm shocked that I have to ask this question. Nowhere in the docs
I'm quite ashemed to ask this question here because I'm sure that I'm missing
I hate to ask this question as I am aware that there are plenty
I sure hope this is an ok question to ask here. I realize it
I'm not too sure how to ask this question. I need to store a
I hope the title is chosen well enough to ask this question. Feel free
Preamble So, this question has already been answered, but as it was my first
I ask this question here because I think this is more a regex question

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.