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

The Archive Base Latest Questions

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

Heres my scenario. I have a table with 3 rows I want to return

  • 0

Heres my scenario.

I have a table with 3 rows I want to return within a stored procedure, rows are email, name and id. id must = 3 or 4 and email must only be per user as some have multiple entries.

I have a Select statement as follows

SELECT
     DISTINCT email,
     name,
     id
from table
where
     id = 3
     or id = 4

Ok fairly simple but there are some users whose have entries that are both 3 and 4 so they appear twice, if they appear twice I want only those with ids of 4 remaining. I’ll give another example below as its hard to explain.

Table –

Email              Name    Id
jimmy@domain.com   jimmy   4
brian@domain.com   brian   4
kevin@domain.com   kevin   3
jimmy@domain.com   jimmy   3

So in the above scenario I would want to ignore the jimmy with the id of 3, any way of doing this without hard coding?

Thanks

  • 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:26:53+00:00Added an answer on June 7, 2026 at 1:26 am
    SELECT
         email,
         name,
         max(id)
    from table
    where
         id in( 3, 4 )
    group by email, name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple scenario: table view controller, with 5.000 rows. I have 5000 images name from
Here's my scenario: I have a simple stored procedure that removes a specific set
Here is my scenario: I have table A, that has 4 rows (id, col1,
Here's the scenario: I have 2 tables: CREATE TABLE dbo.API_User ( id int NOT
So here is the scenario: I have a MOSS 2007 box and I want
Here's the scenario: I have a table with 3 columns: 'KeyColumn', 'SubKeyColumn' and 'BooleanColumn',
Here is the scenario: You have a Persons table with a one-to-many relationship with
Ok this is the scenario... I have a table in Oracle that acts like
I have a several tables nested within a table that I am parsing using
Here is my scenario: I have a single table with 2 columns. ID and

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.