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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:30:36+00:00 2026-06-08T12:30:36+00:00

Am trying to resolve the below query. Please could you help? BANKTABLE BT AccountNumber

  • 0

Am trying to resolve the below query. Please could you help?

BANKTABLE BT

AccountNumber   AccountTypeCode     Balance         ShareAccountHolderCount
10800           2146                    160                 5
10800           2148                    126                 3
10800           2149                    84                  6
10800           2147                    66                  7
11039           2581                    42                  1
11039           2582                    32                  21
11039           2579                    10                  91
11039           2578                    7                   10  

Requirement:
1. A Account Number(BT.AccountNumber) might have accounts in multiple AccountTypes(BT.AccountTypeCode) and
for the each account type he might have the different balances(BT.Balance).
2. Under the account for multiple accounttypes, he might have number of Shared account holders(BT.ShareAccountHolderCount)
3. I don’t have another table to join with the BANKTABLE

Question: Now I have to pick up the the Max(Balance) and its ShareAccountHolderCount for the account number from the all the account types

The Result Should look like as below.

AccountNumber   AccountTypeCode     Balance         ShareAccountHolderCount
10800           2146                    160                 5
11039           2581                    42                  1  

As per my research
Answer 1: TOP 1 and Order by Balance DESC Won’t work for this requirement.
Answer 2: Am trying to do something by writing below query, But not able to achieve the answer

SELECT AccountNumber,AccountTypeCode,Balance,ShareAccountHolderCount
        ,RowNumber = ROW_NUMBER() OVER (PARTITION BY AccountNumber ORDER BY  LongestStressdays DESC)
        ,RowNumber2 = ROW_NUMBER() OVER (PARTITION BY AccountNumber ORDER BY  CountOfTestTypeIdsperSequence DESC)
        FROM BANKTABLE BT
  • 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-08T12:30:38+00:00Added an answer on June 8, 2026 at 12:30 pm

    You are near of solution. Second part consist in filter rows to get only the first row by partition:

    with cte as (
       SELECT 
           AccountNumber,
           AccountTypeCode,
           Balance,
           ShareAccountHolderCount,
           RowNumber = ROW_NUMBER() OVER (
                   PARTITION BY AccountNumber 
                   ORDER BY  Balance DESC)
       FROM BANKTABLEL BT
    )
       select
         AccountNumber,
         AccountTypeCode,
         Balance,
         ShareAccountHolderCount
       from
         cte
       where RowNumber = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use Jquery to resolve my below issue. I have got
I was just trying the below code and it is not working.. please suggest
I'm trying to resolve an IEnumerable of my dependencies through Autofac, but I need
I am trying to resolve a warning shown on the Facebook linter. The parser's
I'm trying to resolve a hostname in PHP and can't use the builtin gethostbyname
I am trying to resolve a 100% cpu usage by the SQL Server process
I am going nuts here trying to resolve a cascading update/delete issue :-) I
So, I'm having a hard time trying to resolve a college problem... What I
I'm trying to figure out how to resolve relatively referenced resources inside dynamically loaded
I'm becoming mad trying to figure out how to resolve this task. My goal

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.