i have 2 tables
table-1
employeeid employeename 1 table-2
employeeid month 1 jan 1 feb 1 mar 1 apr when apply inner join based on employeeid result this
employeeid employeename month 1 jan 1 feb 1 mar 1 apr i want remove repeating column values table-1. result should this.
employeeid employeename month 1 jan feb mar apr please suggest ideas on this.
this job:
with cte ( select t1.employeeid t1employeeid, t1.employeename, t2.employeeid t2employeeid, month, rn = row_number() on (partition t1.employeeid order month(t2.month + ' 1 2015')) table2 t2 left outer join table1 t1 on t1.employeeid = t2.employeeid ) select employeeid = case when rn = 1 t1employeeid else null end, employeename = case when rn = 1 employeename else null end, month cte the tricky part ordering int-month abbreviated month name.
Comments
Post a Comment