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

The Archive Base Latest Questions

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

I have been looking to see how I would apply logic in my SQL

  • 0

I have been looking to see how I would apply logic in my SQL query to accomplish my goal. I am open to any suggestions at this point.

I have two tables that I have an inner join between. The two tables being a complete listing of all MLB baseball players (past & present), and a table of all of the Hall of Famer players. I am looking to come up with a query result of one unique player per row and have a column filled in with a Y or an N if they are in the Hall of Fame.

Table 1 – Players

ID
HallofFameID
NameFirst
NameLast

Table 2 – HallOfFame

HallofFameID
YearID
Votes
Inducted

Each player has one entry in the Players Table but may have their PlayerID entered multiple times in the Hall of Fame Table. In my resulting query with inner joins will pull up rows that will look like this…

Player ID  |   NameFirst  |  NameLast  |  YearID  |  Votes  |  Inducted

001........| Don.........| Sutton......| 1992.....| 100.....| N

001........| Don.........| Sutton......| 1993.....| 89......| N 

001........| Don.........| Sutton......| 1994.....| 100.....| N   

001........| Don.........| Sutton......| 1998.....| 341.....| Y

002........| Mickey......| Mantle......| 1974.....| 341.....| Y So forth...

I would like my resulting query to not display the rows from 1992-1997 where Don Sutton was not elected, but just display the 1998 year, and then move down to the Mickey Mantle row with a Y. Also there are other players who have not been elected, that have a N next to their names for multiple years of Hall eligibility that I need to display on the same query result.

I have included my working SQL for reference. I am not looking for anyone to write my SQL, but rather point me in the right direction with keywords, or logic that I may be missing.
Thanks in advance

Select  DISTINCT
    Master.namefirst, 
    Master.nameLast, 
    Master.HofID,
    HallOfFame.inducted,
    HallOfFame.yearid
FROM 
    HallOfFame 
INNER JOIN 
    Master On HallOfFame.hofID = Master.hofID
Group by 
    Master.nameFirst,
    Master.nameLast,
    Master.PlayerID,
    Master.hofID,
    HallOfFame.inducted,
    HallOfFame.yearid*
  • 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-15T23:16:56+00:00Added an answer on June 15, 2026 at 11:16 pm

    Try this instead:

    SELECT
      m.namefirst, 
      m.nameLast, 
      m.HallofFameID,
      h1.inducted,
      h1.yearid
    FROM HallOfFame h1
    INNER JOIN
    (
       SELECT PlayerID, MAX(YearID) LatestYear
       FROM HallOfFame 
       GROUP BY PlayerID
    ) h2 ON h1.PlayerID = h2.PlayerID AND h1.YearID = h2.LatestYear
    INNER JOIN players m On h1.PlayerId = m.Id;
    

    SQL Fiddle Demo

    This will give you:

    | NAMEFIRST | NAMELAST | HALLOFFAMEID | INDUCTED | YEARID |
    -----------------------------------------------------------
    |       Don |   Sutton |            1 |        Y |   1998 |
    |    Mickey |   Mantle |            2 |        Y |   1974 |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking over this code for the past hour, I cant see
I have been looking with no success to see if I can dynamically apply
I have been looking at the source code of raphael.js and I see a
Alright so I have been looking around (on SO and Google) to see if
I have been looking around for a visualization framework that would aid graph visualization
I have been looking for an answer to this on Stack Overflow, but I
I have been looking all over the Internet for an answer to this question
I have been looking at this for hours but can't find out what's wrong.
Have been looking around for a solution to this and have found some help
I have been looking around for hours on how to do this, I think

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.