Solved

SQL help

Posted on 2012-04-10
2
316 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
2 Comments
 
LVL 42

Expert Comment

by:dqmq
Comment Utility
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 31

Accepted Solution

by:
awking00 earned 500 total points
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

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 setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now