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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:15:58+00:00 2026-06-06T23:15:58+00:00

I have a table with 2 columns, following is my table structure referral_id |

  • 0

I have a table with 2 columns, following is my table structure

referral_id | status

531 | 0
531 | 0
531 | 3
530 | 3
529 | 3
528 | 3
527 | 3
527 | 0
527 | 0
523 | 2
523 | 0
523 | 3
522 | 3
522 | 3
522 | 3
522 | 3
511 | 3

My expected output is

referral_id | status

530 | 3
529 | 3
528 | 3
522 | 3
511 | 3

The 1st column referral_id can have multiple tuples with same id (see referral_id’s 531 and 527). I need to make sure that tuples with same referral_id get eliminated if all of their corresponding “status” are NOT 3. If all of the corresponding “status” are 3 then I need to apply GROUP BY to get that referral_id(s) in result. “status” column can have values from 1 to 4, but I just need to look for 3. So how can I achieve this result ?

  • 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-06T23:16:05+00:00Added an answer on June 6, 2026 at 11:16 pm

    what about …

    select referral_id, max(status)
    from tablename
    group by referral_id
    having max(status) = 3 and max(status) = min(status)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a hierarchical (tree structure) SQL Server table TEmployee with following columns Id
I have a table which have the following structure, the columns are origin, destination,
Working in a Rails App, I have the following table structure (pertinent columns only)
I have a Tickets table with somewhat following structure (removed unnecessary columns) int |
I have a table with the following structure: -------------- SHOW COLUMNS FROM versions --------------
Lets say I have table with following columns 1. Client - string. 2. Profit
I have a table with following columns: ContractorId ......... INT ............. IDENTITY ContractorName ........
I have a table with the following columns in SQL Server: MEMBERID, MEMBEREMAIL, FATHEREMAIL,
I have a table with the following columns: ref_year, ref_no, inv_id, start_date, end_date The
I have a table that contains the following columns: ID int, DISTANCE float, EVENT

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.