I am trying to create a query to pull up not only the unit cost but also the sum total of an order (sum(unitcost)) and return it to the result set for every line Item. I am writing this for a report and I will filter the data there. I am trying to avoid using a sub report. Here is where I am at so far. I have adapted my example for the nothwind db.
select
Sum (od.unitprice),
e.lastname+', ' + e.firstname as emloyee,
od.orderid,
p.productname,
od.unitprice
from orders o
join orderdetails od on o.orderid=od.orderid
join employees e on o.employeeid=e.employeeid
join products p on od.productid=p.productid
where o.orderid = 10248
group by
od.orderid,
e.lastname,
e.firstname,
od.unitprice,
p.productname
select
Sum (od.unitprice),
e.lastname+', ' + e.firstname as emloyee,
od.orderid,
p.productname,
od.unitprice
from orders o
join orderdetails od on o.orderid=od.orderid
join employees e on o.employeeid=e.employeeid
join products p on od.productid=p.productid
where o.orderid = 10248
group by
od.orderid,
e.lastname,
e.firstname,
od.unitprice,
p.productname