Solved

SQL help

Posted on 2012-04-10
2
318 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
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 500 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle 12c patching 1 81
Difference in number of minutes between 2 timestamps 16 51
Oracle Listener Not Starting 11 44
Create Index on a Materialized View 5 22
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
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
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.

770 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