sql server 2008 - Not contained in aggregate or having. . -


back query again. thought doing correctly subquery. . .

use northwind select * ( select firstname + ' ' + lastname 'full name', sum(unitprice * quantity) 'total sales', year(orderdate) salesyear employees e join orders o on o.employeeid = e.employeeid join orderdetails od on od.orderid = o.orderid) subst group 'full name', salesyear   order 'total sales' desc 

the error "invalid in select list because isn't contained in either aggregate function or group clause. had without subquery earlier , worked fine . . .

the aggregate function (e.g. sum) , grouping have done @ same "level" of query:

use northwind select 'full name',salesyear,sum(sale) 'total sales' (     select firstname + ' ' + lastname 'full name',     unitprice * quantity sale,     year(orderdate) salesyear     employees e        join orders o on o.employeeid = e.employeeid        join orderdetails od on od.orderid = o.orderid) subst group 'full name', salesyear   order 'total sales' desc 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -