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
Post a Comment