sql server - Duplication of data in SQL Query -
i'm having issue there data duplication on query.
this how issue looks like.
i have view table data of: (ps_cx_finc_sf_p_vw)
id | item_term | item_amt | item_type | date | item_no ------------------------------------------------------ 005976 | 1609 | 3000.00 | c | 2016-09-27 | 00010
(ps_cx_finc_sf_a_vw)
id | item_term | item_amt | item_type | date | item_no -------------------------------------------- 005976 | 1609 | -50.00 | p | 2016-09-27 | 00009 005976 | 1609 | -100.00 | p | 2016-10-04 | 00011 005976 | 1609 | -50.00 | p | 2016-10-23 | 00012
what hope results:
id | item_amt | date | item_no | item_amt | date | item_no ---------------------------------------------- 005976 | 3000.00 | 2016-09-27 | 00010 | -50.00 | 2016-09-27 | 00009 005976 | null | null | null | -100.00 | 2016-10-04 | 00011 005976 | null | null | null | -50.00 | 2016-10-23 | 00012
but result becoming this:
id | item_amt | date | item_no | item_amt | date | item_no ---------------------------------------------------------- 005976 | 3000.00 | 2016-09-27 | 00010 | -50.00 | 2016-09-27 | 00009 005976 | 3000.00 | 2016-09-27 | 00010 | -100.00 | 2016-10-04 | 00011 005976 | 3000.00 | 2016-09-27 | 00010 | -50.00 | 2016-10-23 | 00012
this query:
select a.id, a.item_amt, a.date, a.item_no, b.item_amt, b.date, b.item_no ps_cx_finc_sf_p_vw left join ps_cx_finc_sf_a_vw b on (a.emplid = b.emplid , a.item_term = b.item_term) a.emplid = '00000005976' , a.item_term = '1609'
the requirement show these 2 types of payment in 1 rows. can't find way make data first type showing 1 row.
my table key id , item_term, date , item_type , item_no
try having date
in join , use table b main table , table in left join
select b.id, a.item_amt, a.date, a.item_no, b.item_amt, b.date, b.item_no ps_cx_finc_sf_a_vw b left join ps_cx_finc_sf_p_vw on (a.emplid = b.emplid , a.item_term = b.item_term , a.date = b.date) b.emplid = '00000005976' , b.item_term = '1609';
hope should solve problem.
Comments
Post a Comment