| 
                
Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with. 
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | Swati JainPosting Yak  Master
 
 
                                        139 Posts | 
                                            
                                            |  Posted - 2007-10-04 : 09:30:24 
 |  
                                            | declare tmpsum_1 float,avg_1 floatI triedinsert into tmp values (sum_1 , avg_1)select sum(col1) as sum_1,avg(col1)as avg_1then I got the errorThe name "sum_1" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.same for "avg_1"What needs to be done? |  |  
                                    | DonAtWorkMaster Smack Fu Yak Hacker
 
 
                                    2167 Posts | 
                                        
                                          |  Posted - 2007-10-04 : 11:53:18 
 |  
                                          | [code]declare @foo table(col1 int, col2 int)insert into @fooselect 1,2 union all select 3,9 union all select 6,4 union all select 3,23 union all select 8,2 union all select 3,3 declare @tmp table(sum_1 float,avg_1 float)insert into @tmp (sum_1 , avg_1)select sum(col1) ,avg(col1)from @fooselect * from @tmp[/code][Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |  
                                          |  |  |  
                                |  |  |  |  |  |