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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:14:35+00:00 2026-06-01T02:14:35+00:00

I would appreciate some help on creating the proper SQL to retrieve only one

  • 0

I would appreciate some help on creating the proper SQL to retrieve only one value for matching records in my 3rd table “table C” as shown below. Table A lists customers ID, name and state. Table B lists foreign key customers ID and member card number. Table C lists sales for member card number.

select  A.cifno, A.cfna1, A.cfstate, B.hbmast.cifno, B.hbmast.hbcid,  C.cast(ewmast.ewcid as dec(12,0)) as "eWire ID"
from library.cfmast cfmast join library.hbmast hbmast
on cfmast.cfcif# = hbmast.cifno left join library.ewmast ewmast
on hbmast.hbcid = cast(ewmast.ewcid as dec (12,0))

Sample data:

table A
**A.cifno, A.cfna1, A.cfstate**
J00022, John, OH
B00019, Ben, TX


table B
**B.hbmast.cifno, B.hbmast.hbcid**
J00022, 555500001234
B00019, 555500007878


table C
**ewmast.ewcid**
555500001234
555500001234
555500001234
555500007878

Desired output is:

J00022, John, OH, J00022, 555500001234, 555500001234
B00019, Ben, TX, B00019, 555500007878, 555500007878

— NOT —

J00022, John, OH, J00022, 555500001234, 555500001234
J00022, John, OH, J00022, 555500001234, 555500001234
J00022, John, OH, J00022, 555500001234, 555500001234
B00019, Ben, TX, B00019, 555500007878, 555500007878
  • 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-01T02:14:36+00:00Added an answer on June 1, 2026 at 2:14 am

    You should use the keyword distinct in your select.

    I.e., something like:

    select distinct ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would appreciate some help with something I working on and have not done
I would appreciate some help with an UPDATE statement. I want to update tblOrderHead
I have a problem finding references to this subject and would appreciate some help.
I'm pretty new to Python programming and would appreciate some help to a problem
I would really appreciate it if some of you could help optimize my tables,
I would appreciate some help refactoring my code. If I pass an instance of
I would appreciate some guidance on modelling services and operations in WCF. I have
I have a design issue that I would appreciate some input on. I would
I'm currently looking into using WIF for an upcoming project and would appreciate some
I would really appreciate some feedback on what I am trying to achieve: The

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.