I have two orders and each order can have a few parts. I am looking for the combined commission for each order. Here is the query...
Code:
SELECT TRIM(c.first)||' '||c.last AS "Customer Name", o.order_number, TRIM(sr.first)||' '||sr.last AS "Customer
Rep",TO_CHAR(ROUND((ol.number_ordered * ol.quoted_price) * sr.commission_rate,2), '$9,999.99')"Total Commission"
FROM customer c, sales_rep sr, orders o, order_line ol
WHERE sr.slsrep_number = c.slsrep_number
AND c.customer_number = o.customer_number
AND o.order_number = ol.order_number
AND c.zip_code = 49441;
Here is what is returned to me..
CusName OrdNum SalesRep Comm.
Mary Nelson 12498 Miguel Diaz $1.30
Mary Nelson 12498 Miguel Diaz $4.99
Mary Nelson 12504 Miguel Diaz $32.60
This is what I am looking for...
Mary Nelson 12498 Miguel Diaz $6.29
Mary Nelson 12504 Miguel Diaz $32.60
(I'm so close!)
First thing I tried was changing the TO_CHAR(ROUND((.... to
TO_CHAR(SUM((. Then adding a GROUP BY, but TRIM(c.first) was invalid.
Then I tried to format the "Total Commission" in the Column and that was a total fail... So any advice would be appreciated.