Create table #temp1 ( invoicenumber int, store varchar(255), purchasedate datetime, itemtype varchar(255), totalprice money ) Create table #temp2 ( invoicenumber int, amount money ) Insert INTO #temp1 SELECT A.invnum, L.locationname, R.pdate, A.type, A.unitprice * A.quantity From acct A inner join locations L on A.store = L.name inner join reports R on A.invoice = R.invnum Insert INTO #temp2 Select invoicenumber, sum(totalprice) From #temp1 Group by invoicenumber
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)