Link to home
Start Free TrialLog in
Avatar of j2911
j2911

asked on

SQL help

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.
Avatar of dqmq
dqmq
Flag of United States of America image

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;
ASKER CERTIFIED SOLUTION
Avatar of awking00
awking00
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial