简体   繁体   English

我可以在DB2中创建动态列名吗?

[英]Can I create Dynamic Column Names in DB2?

I two tables, one table contains the names of columns, the other table contains the actual data that I need to display in a report. 我有两个表,一个表包含列名,另一个表包含我需要在报表中显示的实际数据。 The data and columns are linked by a column key. 数据和列通过列键链接。

Is there a way to build a select statement that can use the column name from the column table for the actual temp table column? 有没有一种方法可以构建一个选择语句,该语句可以将列表中的列名用于实际的临时表列?

Something like this; 像这样的东西;

Select A.value AS B.ColumnName 

Simply put Can I create a table column name based on the value in another table in sql? 简而言之,是否可以基于sql中另一个表中的值创建表列名?

You can´t do it without using dynamic SQL as mentioned question that can be useful for you. 如果不使用动态SQL(如前所述)可能对您有用,那么您将无法做到。

SQL Server: How to set column alias from another table during select? SQL Server:如何在选择过程中从另一个表设置列别名?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM