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

  • Home
  • SEARCH
  • 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 6771987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:29:48+00:00 2026-05-26T15:29:48+00:00

I want a query to select more than 4 AccountId repetitions from table2 having

  • 0

I want a query to select more than 4 AccountId repetitions from table2 having distinct name in table1

Here are the table structures:

table1                             |       Table2
ID   AccountNumber  Name           |       ID       AccountNumber AccountID
1     12345         John Jeff      |        1          12345        A467T
1     12345         Patrick Jones  |        1          12345        A467T

ID and AccountNumber are the same on both tables

  • Table1 has Name
  • Table2 has AccountID
  • 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-26T15:29:48+00:00Added an answer on May 26, 2026 at 3:29 pm

    Here’s a query to find AccountID’s with more than 4 different names:

    select  t2.AccountID
    from    Table1 as t1
    join    Table2 as t2
    on      t1.AccountNumber = t2.AccountNumber
            and t1.ID = t2.ID
    group by
            t2.AccountID
    having  count(distinct t1.Name) > 4
    

    If that’s not what you were looking for, please clarify the question! For examole, you could add desired output.

    EDIT: In reply to your comment, you could query the ID and Numbers with a subquery:

    select  distinct 
            ID
    ,       AccountNumber
    ,       AccoutnID
    from    Table2
    where   AccountNumber in 
            (
            ... place query from above here ...
            )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want a Codeigniter select query from a table with three conditions in .
I want to write a query to select from a table all rows with
I have an oracle sql query select distinct tab1.col1, tab2.col1 from table1 tab1 join
I have the following query: SELECT wm_concat(DISTINCT NAME) as Methods FROM TPM_TRAININGPLAN JOIN TPM_DELIVERYMETHODS
I want select multiple (all) values from table Account. string query = SELECT *
I'm running the folowing query: SELECT DISTINCT hardware_id, model, make from Table1 order by
I want to build the following pseudo query Select a From APDU a where
I have the following query: SELECT carBrand, carYear, carModel FROM Cars; What I want
I want to consolidate values in my table using SELECT Query. My table has
I want to remove duplicate rows return from a SELECT Query in Postgres I

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.