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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:44:07+00:00 2026-05-25T00:44:07+00:00

Below is my query that I am using: SELECT County, Code, Sum(PaidAmount) AS TotalPaid

  • 0

Below is my query that I am using:

SELECT 
   County,
   Code,
   Sum(PaidAmount) AS TotalPaid
FROM
   Counties
GROUP BY
   County,
   Code

It returns the set:

County     Code         TotalPaid
Brown      99           210.21
Lyon       73           322.22
Lyon       88           533.22
Lincoln    22           223.21

What I am looking for is a query that will return the rows that show the County and the Code for the Max TotalPaid for each County. An example of the result set that I need is shown below (notice that Lyon, 73 is removed since Lyon, 88 has a higher TotalPaid amount):

County     Code         TotalPaid
Brown      99           210.21
Lyon       88           533.22
Lincoln    22           223.21
  • 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-25T00:44:07+00:00Added an answer on May 25, 2026 at 12:44 am

    I wasn’t able to test this, but RANK should solve this:

    SELECT x.County, x.Code x.TotalPaid
        ,RANK() OVER 
        (PARTITION BY x.County ORDER BY x.TotalPaid DESC) AS 'RANK'
    FROM
    
    (SELECT 
       County,
       Code,
       Sum(PaidAmount) AS TotalPaid
    FROM
       Counties
    GROUP BY
       County,
       Code) x
    WHERE Rank = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very large query that follows the format below: select ... from
I have a query that returns a result set similar to the one below:
I'm using VB.NET. I am performing a select query that returns approximately 2500 rows,
What does the below query explain? SELECT * FROM `jos_menu` WHERE (id = 69
I have a MySQL query below that I'm using to get events for my
Please look at the below query select DATEADD(wk, DATEDIFF(wk, 6, creation_ts), 6) creation_ts ,sum(case
I have below a working query that needs to be simplified. The reason is
I would like to convert the below foreach statement to a LINQ query that
Please help me figure a single query that will transform the data below... |id
I've got a query below. I want to add a condition that if the

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.