SQL : Select a dynamic number of rows as columns

前端 未结 4 1251
春和景丽
春和景丽 2021-01-22 23:21

I need to select static colums + a dynamic number of rows as columns in SQL

TABLE 1
-------
HotelID
BlockID
BlockName

TABLE 2
-------
BlockDate (unknown number          


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-22 23:54

    Do this in the client.

    SQL is a fixed column language: you can't have a varible number of columns (even with PIVOT etc). Dynamic SQL is not a good idea.

提交回复
热议问题