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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:24:56+00:00 2026-06-14T16:24:56+00:00

I met some trouble while using mysql, In fact I have a table formated

  • 0

I met some trouble while using mysql, In fact I have a table formated like that:

n_doss   etat     date       etc...
-----------------------------------
145        N      20/10
145        EC     15/10
146        N      25/10        

What I would like to do is for each etat to count how much folder I have (folders are identified by n_doss).

the trouble is that the last etat that is important is the most recent for each file.

So I have to count for each etat how much file I have, but I can not count each etat for each n_doss but just the most recent.

I’ve tried almost everything but I can not succeed in this query.

I’ve tried:

SELECT  `etat` , `n_doss`, COUNT(  'etat' ) 
FROM  `commentaire` WHERE  
GROUP BY  `etat` 

This does not work with what I try to do.

I also tried

SELECT `etat` , `n_doss`, COUNT(  'etat' ) 
FROM  `commentaire`   
GROUP BY  `n_doss`
HAVING max(date) with 

with acualy no success.
Any kind of help will be much appreciated.

  • 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-14T16:24:57+00:00Added an answer on June 14, 2026 at 4:24 pm
    SELECT  a.*, c.totalCOunt
    FROM    commentaire a
            INNER JOIN
            (
                SELECT etat, MAX(date) maxDate
                FROM commentaire
                GROUP BY etat
            ) b ON a.etat = b.etat AND
                    a.date = b.maxDate
            INNER JOIN
            (
                SELECT etat, COUNT(*) totalCOunt
                FROM commentaire
                GROUP BY etat
            ) c ON a.etat = c.etat
    
    • SQLFiddle Demo
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I met some troubles while using PHPExcel, In fact I have read all the
I met some trouble while using input type dates, also I decided for reasons
I met some trouble with a function I have written. In fact I have
I have an implementation that just like gmail application, but have met some problem
I met some trouble with my code, In fact I would like to replace
I met some trouble with a javascript. In fact I have in my database
I have some MET data I want to validate which would look something like
I met some problems while using GDI+ for drawing different images in my program.
I have a MySQL table called items that contains thousands of records. Each record
I met some trouble with javascript and ckeditor. I've done a function that will

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.