SQL assist - hard to difficult - rows to columns
Posted on 2011-09-19
Hi experts - - is this enough info to help me convert two distinct rows that get returned to a single row with multiple columns. I particularly need each sum for each term, with the term listed next to its sum.
select b.national_id, a.emplid, a.account_term,sum(a.line_amt) from ps_item_line_sf a, ps_pers_nid b
where a.emplid = '10837633' and a.account_term in('1116','1119') and a.emplid = b.emplid
group by b.national_id, a.emplid, a.account_term
result desired is: national_id, emplid, term 1116, sum for term 1116, term 1119, sum for term 1119