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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:23:46+00:00 2026-06-07T01:23:46+00:00

What I need to do is to get the MAX value of column col7

  • 0

What I need to do is to get the MAX value of column col7 for each of the distinct values of the column col6. Sample data below. IPX is the PK.

The results should look like

IPX col1    col2    col3    col4    col5    col6    col7
2097177 32  25  1   3   20  10011   19
2097465 32  313 15  5   246 10012   245
2097783 32  631 27  7   440 10013   439

I could select them all into temp tables and get the max but I think there is query to get these results, I just cannot figure it out. Thanks for the help.

IPX    col1 col2    col3    col4    col5    col6    col7
2097157 32  5   0   3   4   10011   3
2097159 32  7   0   5   6   10011   5
2097161 32  9   0   7   8   10011   7
2097163 32  11  0   9   10  10011   9
2097169 32  17  0   11  12  10011   11
2097171 32  19  0   13  14  10011   13
2097173 32  21  0   15  16  10011   15
2097175 32  23  1   1   18  10011   17
2097177 32  25  1   3   20  10011   19
2097440 32  288 14  1   226 10012   225
2097442 32  290 14  3   228 10012   227
2097444 32  292 14  5   230 10012   229
2097446 32  294 14  7   232 10012   231
2097448 32  296 15  15  256 10012   255
2097456 32  304 16  15  272 10012   271
2097457 32  305 14  13  238 10012   237
2097459 32  307 14  15  240 10012   239
2097461 32  309 15  1   242 10012   241
2097463 32  311 15  3   244 10012   243
2097465 32  313 15  5   246 10012   245
2097729 32  577 25  1   402 10013   401
2097731 32  579 25  3   404 10013   403
2097733 32  581 25  5   406 10013   405
2097735 32  583 25  7   408 10013   407
2097737 32  585 25  9   410 10013   409
2097745 32  593 25  11  412 10013   411
2097747 32  595 25  13  414 10013   413
2097749 32  597 25  15  416 10013   415
2097751 32  599 26  1   418 10013   417
2097753 32  601 26  3   420 10013   419
2097760 32  608 26  5   422 10013   421
2097762 32  610 26  7   424 10013   423
2097764 32  612 26  9   426 10013   425
2097766 32  614 26  11  428 10013   427
2097768 32  616 26  13  430 10013   429
2097776 32  624 26  15  432 10013   431
2097777 32  625 27  1   434 10013   433
2097779 32  627 27  3   436 10013   435
2097781 32  629 27  5   438 10013   437
2097783 32  631 27  7   440 10013   439
  • 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-07T01:23:48+00:00Added an answer on June 7, 2026 at 1:23 am

    Try this:

    WITH Data AS
    (
        SELECT  *,
                ROW_NUMBER() OVER(PARTITION BY col6 ORDER BY col7 DESC) AS Position
          FROM  <YOUR-TABLE> a
    )
    SELECT  IPX, col1, col2, col3, col4, col5, col6, col7
      FROM  Data 
     WHERE  Position = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get the biggest value from two fields: SELECT MAX(field1), MAX(field2) Now,
Need your help to get the max of CAP_PRICE based on certain criteria in
I need to get a path to the GIT on Max OS X 10.6
I have two tables with a weak relation. I need get a text value
I need to get the indices of the maximum values of the columns in
I have a data stored in a xml column and need a comma-separated list
I need a cell to display the max value of a range who's row
I need to join another table to my query, and grab the max value
I can get the results that I need, but I need a fast query.
Using Sql Server I want to get max value from two table Table1 ID

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.