Solved

SQL help

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

860 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