I was just playing with SQL queries as It's for a long time I haven't write T-SQL code. I came into an error while creating a table via group by. Look at the following piece of code:
create table MyTable as select id, sum(number) as numbers from AnotherTable group by id
The above code doesn't work. One of the solutions that I found is using Insert Into like below:
select id,sum(number) as numbers INTO MyTable from AnotherTable group by id
that's all!
Category: Data
Tags: Sql Server