Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL help

Posted on 2012-04-10
2
Medium Priority
?
333 Views
Last Modified: 2012-06-27
Hi experts,

I have one table called results:

results.xls

I have another table and it is called ship_info_xml:

ship-info-xml.xls

I’m writing the following sql statement:

select
results.test_id, results.LEFT_DESCR_VALUE_DESC, results.RIGHT_DESCR_VALUE_DESC, results.COMPR_FLD_NAME, ship_info_xml.scnro_id, ship_info_xml.trkng_nbr, ship_info_xml.A, ship_info_xml.B, ship_info_xml.C
from results join ship_info_xml
on results.LEFT_DESCR_VALUE_DESC = ship_info_xml.trkng_nbr
order by results.test_id;

I've tried to use several different joins but I am getting these same results which causes me duplicates that I cannot seem to get rid of:

query-results.xls

This is the results I would like to see but I am not sure how to accomplish this:

Results-I-would-like-to-see.xls

I have made this hopefully easy to process but I need to know how to code this so it will work properly for me, so I need your help.

Thank you.
0
Comment
Question by:j2911
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 42

Expert Comment

by:dqmq
ID: 37828463
Have you tried a "group by" clause

select
results.test_id, results.LEFT_DESCR_VALUE_DESC, results.RIGHT_DESCR_VALUE_DESC, results.COMPR_FLD_NAME, ship_info_xml.scnro_id, ship_info_xml.trkng_nbr, ship_info_xml.A, ship_info_xml.B, ship_info_xml.C
from results join
ship_info_xml
on results.LEFT_DESCR_VALUE_DESC = ship_info_xml.trkng_nbr
group by
results.test_id, results.LEFT_DESCR_VALUE_DESC, results.RIGHT_DESCR_VALUE_DESC, results.COMPR_FLD_NAME, ship_info_xml.scnro_id, ship_info_xml.trkng_nbr, ship_info_xml.A, ship_info_xml.B, ship_info_xml.C
order by results.test_id;
0
 
LVL 32

Accepted Solution

by:
awking00 earned 2000 total points
ID: 37829040
Try distinct -
select distinct
results.test_id, results.LEFT_DESCR_VALUE_DESC, results.RIGHT_DESCR_VALUE_DESC, results.COMPR_FLD_NAME, ship_info_xml.scnro_id, ship_info_xml.trkng_nbr, ship_info_xml.A, ship_info_xml.B, ship_info_xml.C
from results join
ship_info_xml
on results.LEFT_DESCR_VALUE_DESC = ship_info_xml.trkng_nbr
group by
results.test_id, results.LEFT_DESCR_VALUE_DESC, results.RIGHT_DESCR_VALUE_DESC, results.COMPR_FLD_NAME, ship_info_xml.scnro_id, ship_info_xml.trkng_nbr, ship_info_xml.A, ship_info_xml.B, ship_info_xml.C
order by results.test_id;
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question