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 |
|
Cartier
Starting Member
2 Posts |
Posted - 2012-05-18 : 06:28:56
|
| Hi Guys,I've Created a nested aggregation. However When I run the query in Microsoft SQL express, I get the error below:Msg 207, Level 16, State 1, Line 8Invalid column name 'shpmyear'.Msg 207, Level 16, State 1, Line 8Invalid column name 'shpmarea'.Msg 207, Level 16, State 1, Line 2Invalid column name 'shpmyear'.Msg 207, Level 16, State 1, Line 3Invalid column name 'shpmarea'.This is my query:Select shipmentyear,shipmentarea,avg(System.shpmgwgt) from (Select count(shipmentwgt) AS shpmgwgtfrom dbo.System where shpmyear>=2012) as SystemGroup by shpmyear, shpmareaI'm 100% sure that the colom names are correct.I tried it using it the qeury without the nested aggeretation, I get the right results.Select shipmentyear, shipmentareaFrom dbo.System Where shipmentyear=>=2012Hope some one can help!CheersiSam |
|
|
ashishashish
Constraint Violating Yak Guru
408 Posts |
Posted - 2012-05-18 : 06:51:12
|
| What i suggest you to is select shpmyear and shpmarea in your Sub-Query.I think modifying your sub-query in following manner will help you.Select count(shipmentwgt) AS shpmgwgt,shpmyear, shpmarea from dbo.Systemwhere shpmyear>=2012GROUP BY shpmyear, shpmarea------------------------------------------------The answer is always no till than you don't ask. |
 |
|
|
Cartier
Starting Member
2 Posts |
Posted - 2012-05-19 : 12:33:49
|
I will give it at try and let you know ASAP. Thanks!quote: Originally posted by ashishashish What i suggest you to is select shpmyear and shpmarea in your Sub-Query.I think modifying your sub-query in following manner will help you.Select count(shipmentwgt) AS shpmgwgt,shpmyear, shpmarea from dbo.Systemwhere shpmyear>=2012GROUP BY shpmyear, shpmarea------------------------------------------------The answer is always no till than you don't ask.
|
 |
|
|
|
|
|
|
|