透视单行列 T-SQL
我有一个从查询返回的单行表,看起来像这样
[Date1] [Date2] [Date3] [Date4] [Date5] [Date6]
,我希望所有日期都像这样堆积起来,
[Date1]
[Date2]
[Date3]
[Date4]
[Date5]
[Date6]
如果没有一堆单独的查询和联合语句,我该如何去做呢?我尝试过使用 PIVOT 函数,但很困惑,因为没有任何东西可以聚合行。
I have a one row table returned from a query that looks something like this
[Date1] [Date2] [Date3] [Date4] [Date5] [Date6]
and I want all the Dates to stack up like this
[Date1]
[Date2]
[Date3]
[Date4]
[Date5]
[Date6]
How would I go about doing this without a bunch of separate queries and union statements? I have tried playing around with the PIVOT function but am confused since there is nothing to aggregate the row on.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 UNPIVOT,如下所示:
Try using UNPIVOT, like this: