ユーザーが持っている電話番号の数に自己参加する以外に、選択ステートメントを実行する良い方法は考えられません..そうは言っても、選択ステートメントでこれを試すことができます。
;With CTE_Main as (
Select
id
,Fono
,row_number()
Over(Partition by ID order by Fono) as RN
From sucursales
), CTE_Users as (
Select
id as id_num
from sucursales
group by id
)
Select
id_num
,a.Fono as Phone_1
,b.Fono as Phone_2
,c.Fono as Phone_3
,d.Fono as Phone_4
,e.Fono as Phone_5
From CTE_Users as realz
Left Join [CTE_Main] as a on a.id = realz.id_num and a.RN = 1
Left Join [CTE_Main] as b on b.id = realz.id_num and b.RN = 2
Left Join [CTE_Main] as c on c.id = realz.id_num and c.RN = 3
Left Join [CTE_Main] as d on d.id = realz.id_num and d.RN = 4
Left Join [CTE_Main] as e on e.id = realz.id_num and e.RN = 5
私はその種類が長いことを知っていますが、あなたが望む方法で結果を表示します..私の例では5行しか使用していませんが、それはかなり自明です.
SQL フィドル: http://sqlfiddle.com/#!3/496f6/1