My Code Like
我的代码就像
SELECT col1, Col2, Col3, Col4
INTO #Temp1
FROM Emplyees;
and second Query :
和第二个查询:
SELECT Col1,Sum(Col2)
INTO #Temp2
FROM #temp1
The Second Query Don't Work and gave me Error as Empty or Wrong Aliases column
第二个查询不起作用,并给我错误为空或错误的别名列
untill you Select * From #Temp1 .
This make me ASK why sql accepted * and not for some column Selected .
直到你选择*从#Temp1。这让我问为什么sql接受*而不是某些列选中。
Thanks For all.
谢谢大家。
2 个解决方案
#1
2
SELECT Col1, Sum(Col2) as SumofCol2
INTO #Temp2
FROM #temp1
GROUP BY Col1
#2
1
Well the error is a bit misleading. I would expect it to moan about the lack of a group by clause and the lack of a real name for the second column. Try this:
那么错误有点误导。我希望它对于缺少group by子句以及缺少第二列的真实姓名而抱怨。尝试这个:
SELECT Col1, Sum(Col2) AS SumCol
INTO #Temp2
FROM #temp1
GROUP BY Col1
#1
2
SELECT Col1, Sum(Col2) as SumofCol2
INTO #Temp2
FROM #temp1
GROUP BY Col1
#2
1
Well the error is a bit misleading. I would expect it to moan about the lack of a group by clause and the lack of a real name for the second column. Try this:
那么错误有点误导。我希望它对于缺少group by子句以及缺少第二列的真实姓名而抱怨。尝试这个:
SELECT Col1, Sum(Col2) AS SumCol
INTO #Temp2
FROM #temp1
GROUP BY Col1