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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:29:43+00:00 2026-06-18T05:29:43+00:00

I have this table and I would like to do the following : idstep

  • 0

I have this table and I would like to do the following :

idstep   idproject   beg_date  end_date
   1        1
   2        1
   3        1
   4        1
   1        2
   2        2
   3        2
   4        2
   5        2
   1        3
   2        3
   3        3

Retrieve the Maximum steps for each project without using “GROUP BY”

Using the GROUP BY clause, I get the result that I want which is the following:

  SELECT MAX(idstep), idproject 
    FROM mytable
GROUP BY idproject;

Result:

    idstep     idproject
    4            1
    5            2
    3            3

Please, can anyone here can help me out with this issue?

  • 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-18T05:29:45+00:00Added an answer on June 18, 2026 at 5:29 am

    I agree that this makes more sense to use GROUP BY for this particular case, but this should work:

    SELECT t.project, t.step
    FROM YourTable t
      LEFT JOIN YourTable t2 on t.step < t2.step and t.project = t2.project
    where t2.step IS NULL
    

    And here is the Fiddle.

    You could also use NOT EXISTS (feel like I’ve been using it all night), although I personally prefer the LEFT JOIN / NULL approach:

    SELECT t.project, t.step
    FROM YourTable t
    WHERE NOT EXISTS (
      SELECT *
      FROM YourTable t2 
      WHERE t.step < t2.step 
        AND t.project = t2.project
    )
    

    More fiddle: http://www.sqlfiddle.com/#!2/ebbc2/1

    Good luck.

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

Sidebar

Related Questions

I have this table structure and would like to map it using Fluent Hibernate
I have a table that someone update this table every day. I would like
I have this following code that delete a mysql record and I would like
I have this table : I would like to delete same rows. For example
Within a project I have a database table with the following columns I would
I would like to create a view from the following table. This table contains
i have a table (tbl_world) which look like this id | first_name | last_name
I have UserComments table like this : 1 | Frank | hello world 2
I have a table like this: someid somestring 1 Hello 1 World 1 Blah
Any help here would be greatly appreciated. I have this table hospital Nurse |

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.