x

i am getting error like"Each GROUP BY expression must contain at least one column that is not an outer reference."

update abb_account_budget_tmp
set budget_amount =(select sum(isnull(budget_amount,0.0))
                     from abb_analysis_dtl dtl(nolock)
                   where dtl.sub_analysis_code=a.sub_analysis_code
                    and  dtl.company_code = @companycode_tmp
                    and  dtl.fb_id=@fb
                   group by a.sub_analysis_code)
when i am executing this query i am getting error
more ▼

asked Nov 29, 2011 at 02:09 AM in Default

cstephen gravatar image

cstephen
234 24 27 29

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first
The problem is that there is no such table aliased with "a", hence a.sub_analysis_code should not be used in the sub-query. This is where you get the error. If you can sort out what "a" is, this will get you going.
more ▼

answered Nov 29, 2011 at 02:19 AM

Usman Butt gravatar image

Usman Butt
13.9k 6 8 14

(comments are locked)
10|1200 characters needed characters left

Hi,

The alias name "a" is not referring any table, and work with @Usman Butt answer you may solve this issue
more ▼

answered Nov 29, 2011 at 04:15 AM

sathishkumar gravatar image

sathishkumar
234 22 24 26

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x990
x57

asked: Nov 29, 2011 at 02:09 AM

Seen: 801 times

Last Updated: Nov 29, 2011 at 04:03 AM