Sql 基于子查询创建表

Sql 基于子查询创建表,sql,Sql,我一直试图通过捕获一些列并将其中一些列连接在一起来创建一个新表。我尝试过不同的变化,但没有乐趣。当前我收到一个错误,列名称丢失或为空 select [company_code] ,[ftds_opening_balance] ,[ftds_closing_balance] ,(select [prime_account_code]+'-'+[sub_account_code] as GL_Account from [output]

我一直试图通过捕获一些列并将其中一些列连接在一起来创建一个新表。我尝试过不同的变化,但没有乐趣。当前我收到一个错误,列名称丢失或为空

select [company_code] 
        ,[ftds_opening_balance]
        ,[ftds_closing_balance]
        ,(select [prime_account_code]+'-'+[sub_account_code] as GL_Account
        from [output].[trial_balance]
            )
into[output].[trial_balance2013]
from [output].[trial_balance]
where period_year = '2013'

得到错误的部分可能是

    ,(select [prime_account_code]+'-'+[sub_account_code] as GL_Account
    from [output].[trial_balance]
        )
在某些数据库中,将向您发送一条消息,说明存在多个值。
查询中已经有相同的表,因此从中获取值将得到相同的结果

select [company_code] 
     , [ftds_opening_balance]
     , [ftds_closing_balance]
     , [prime_account_code] + '-' + [sub_account_code] as GL_Account
into   [output].[trial_balance2013]
from   [output].[trial_balance]
where  period_year = '2013'
并非所有数据库都使用“+”连接字符串,例如Oracle使用| |,因此计算列应为

    ,[prime_account_code] || '-' || [sub_account_code] as GL_Account

另外,
prime\u account\u code
sub\u account\u code
应该是字符串数据类型,或者转换为字符串数据类型,以便能够将它们连接起来

谢谢。我把它复杂化了