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

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

jQuery Ajax Render Fragments OR Whole Page -

java - Why is BlockingQueue.take() not releasing the thread? -