I need to retrieve the distinct values of both the column and row. The oracle sql query in the current setup is given below:
select distinct ym.wh_id,
ym.trlr_num,
ym.arrdte,
ri.invnum,
ri.supnum
from rcvinv ri, yms_ymr ym
where ym.trlr_cod='RCV'
and ri.trknum = ym.trlr_num
and ym.wh_id <=50
and ym.trlr_stat in ('C','CI','R','OR')
and ym.arrdte is not null
order by ym.arrdte desc;
The above returns the output as follows:
> Trailer Number Arrived PO Vendor
> Trailer4 5/12/2015 010025790692 00101
> Trailer5-V6661 5/12/2015 010025754823 00110
> Trailer2-V6651 5/12/2015 010025781421 55395
> TRAILERS1-V6641 5/12/2015 010025790388 00915
> DEV110501-V6631 5/11/2015 010025790692 00101
> Rj-V6621 5/11/2015 010025790692 00101
> 12345-V6601 5/8/2015 010025751682 00128
> 12345-V6601 5/8/2015 010025754823 00110
I require the output as follows:
> Trailer Number Arrived PO Vendor
> Trailer4 5/12/2015 010025790692 00101
> Trailer5-V6661 5/12/2015 010025754823 00110
> Trailer2-V6651 5/12/2015 010025781421 55395
> TRAILERS1-V6641 5/12/2015 010025790388 00915
> 12345-V6601 5/8/2015 010025751682 00128
As you can see, the repeated outputs for PO (010025790692 and 010025754823) and trailer number(12345-V6601) have been removed.
So in short, I want to modify the query such that I get the distinct of both the row and the column as in the below output. Please help. Thanks.