You are on page 1of 2
tm SQL| Ls Result| “SELECT bp.product_id, sum( so.sales_amount ), so.region_id from PRODUCT as bp INNER JOIN SALES as so on bp.product_id = so.product_id GROUP BY bp.product_id, so.region_id PRODUCTID REGIONID SUM(SALES AMOUNT) 1 1 1 100 2 2 1 90 3 5 1 85 4 2 2 80 5 1 2 75 6 3 3 85 7 4 4 75 8 1 5 65 9 2 5 65 i 9, & 1 Group by cause funda fox \When we aggregate colurms using SUM, MIN, MAX, AVG, COUNT and i we are selecting multiple columns from db table, All the columns which are not include inside aggregate functions MUST be part of group by clause. Caleuat total gross amount based on order size, for every customer we want to see total of gross ofall orders more than 1000 and total of goss where order size was < 1000 Some more limitations & Features: > Now we have right outer jin available, table? lef outer jin Table t There is possibilty that there are business partner but need not \ Necessarily have placed any order to me. [want a report ofall sles order total of gross amount and customer names who have not ordered anything at al > Possible to provide bracketing for joins 2 New functionality in ON condition of joins > Number of tables which can participate in joins are now 50, eater we can include only 9 ablesin a join > Maximum no of subqueries has been aso increased to 50 from 9 > We can use USING CLIENT keyword instead of CLIENT SPECIFIED 6 ° Spec 1. Check how long on average invoices has been outstanding from customers (customer wise report) ‘+ Step 1: get all the open invoices from invoice header table which are papas, get the customer id ‘Table name: SNWD_INV_HEAD condition: * Step 2: Loop at each open invoice (unpaid) calculate the total days since when its open, how many invoices ate open, total days / no of inw 2. Check the total gross amount of invoice in a “common currency” *+ Step 1: get the items from invoice item table (shipped) , inv header to get open ing, bpa table for customer names. inv item = SNWD_INV_ITEM condition —all tems for an open invoice (unpaid) inw head = SNWD_INV condition ~ payment. status =" busines part = SNWD_BPA condition — only those for which iny are open (JOIN) + Step 2: Loop at each item and does a currency conversion of gross amount to a common currency lets say EUR. + Step 3: Calculate the total gross amount which is pending per customer D 3. Classify the customer regarding his ability to pay his bills (based on threshold values of days and amount) 4. Perform a dunning (process of sending mass communication to customers reg. their payment notification) 5. Check sales history for customer. o °

You might also like