功能为As的功能

时间:2015-07-27 10:04:45

标签: sql vba

SELECT Left(Code,3) As Code, Count(Left(Code,3)) As CPC 
INTO newtable 
FROM TEST  
GROUP BY Left(Code,3) 

第二名:

SELECT Left(Code,3), Count(Left(Code,3)) As CPC 
INTO newtable 
FROM TEST  
GROUP BY Left(Code,3) 

嗨我这个代码有问题。首先不工作,但第二个是,我认为问题在于左()作为任何人都可以帮助我如何解决它?谢谢: - )

2 个答案:

答案 0 :(得分:0)

尝试使用不同的别名

SELECT Left(Code,3) As Code_new, Count(Left(Code,3)) As CPC 
INTO newtable 
FROM TEST  
GROUP BY Left(Code,3)

答案 1 :(得分:0)

问题是您的第一列没有column name。您需要提供一些名称,您无法创建没有列名称的表

SELECT Left(Code,3) as L_CODE, Count(Left(Code,3)) As CPC 
INTO newtable 
FROM TEST  
GROUP BY Left(Code,3)