Reputation: 53
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 .
Thanks For all.
Upvotes: 1
Views: 262
Reputation: 3327
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:
SELECT Col1, Sum(Col2) AS SumCol
INTO #Temp2
FROM #temp1
GROUP BY Col1
Upvotes: 1
Reputation: 886
SELECT Col1, Sum(Col2) as SumofCol2
INTO #Temp2
FROM #temp1
GROUP BY Col1
Upvotes: 2