x
login about faq Site discussion (meta-askssc)

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 '11 at 02:09 AM in Default

cstephen gravatar image

cstephen
154 9 16 20

(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 '11 at 02:19 AM

Usman Butt gravatar image

Usman Butt
13.8k 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 '11 at 04:15 AM

sathishkumar gravatar image

sathishkumar
234 15 21 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.

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



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x913
x50

asked: Nov 29 '11 at 02:09 AM

Seen: 458 times

Last Updated: Nov 29 '11 at 04:03 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.