select order_number, line_number,
isnull(max(case when linenum=1 then name else null end),'') name1 ,
isnull(max(case when linenum=1 then value else null end),'') value1,
isnull(max(case when linenum=2 then name else null end),'') name2,
isnull(max(case when linenum=2 then value else null end),'') value2,
isnull(max(case when linenum=3 then name else null end),'') name3,
isnull(max(case when linenum=3 then value else null end),'') value3,
isnull(max(case when linenum=4 then name else null end),'') name4,
isnull(max(case when linenum=4 then value else null end),'') value4,
isnull(max(case when linenum=5 then name else null end),'') name5,
isnull(max(case when linenum=5 then value else null end),'') value5,
isnull(max(case when linenum=6 then name else null end),'') name6,
isnull(max(case when linenum=6 then value else null end),'') value6,
isnull(max(case when linenum=7 then name else null end),'') name7,
isnull(max(case when linenum=7 then value else null end),'') value7,
isnull(max(case when linenum=8 then name else null end),'') name8,
isnull(max(case when linenum=8 then value else null end),'') value8,
isnull(max(case when linenum=9 then name else null end),'') name9,
isnull(max(case when linenum=9 then value else null end),'') value9
from (select *, row_number() over(partition by order_number, line_number order by order_number, line_number) linenum
from (SELECT A.order_number, A.TOP_MODEL_LINE_ID, C.CHARGE_NAME, C.CHARGE_VALUE from TABLE1 A, TABLE2 B ,TABLE3 C where C.list_line_id=B.list_line_id AND C.line_id=A.TOP_MODEL_LINE_ID and A.order_number="4411001286")b)a
group by order_number, line_number
20
solved SQL function PIVOT with 2 column