x
login about faq Site discussion (meta-askssc)

Cannot perform an aggregate function on an expression containing an aggregate or a subquery

max(case when datediff(YY,max(birth_date1),getdate()) > 18 then dep_first_name1 else 0 end) maj_dep_first_name

When I run my procedure with the above statement I get teh error: Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

Any help is appreciated. Thanks RTSFO

more ▼

asked Dec 04 '09 at 08:49 PM in Default

RTSFO gravatar image

RTSFO
1 1 1 1

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

1 answer: sort oldest

you have a max() within another max()

try removing the outer max()

case when datediff(YY,max(birth_date1),getdate()) > 18 then dep_first_name1 else 0 end            

if does not work, please post your full query

more ▼

answered Dec 04 '09 at 11:29 PM

Squirrel 1 gravatar image

Squirrel 1
1.6k 1 3

(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.

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.