Hi @BaileyGross12
Firstly, this is very difficult; not exactly a basic SQL requirement! Anybody, regardless of skill would find this difficult.
You are trying to do an aggregation of data - there are 2 ways to do this. You can either do it in the lobby data source, or in the element.
In this case, I think you need to do it inside the data source.
You need to add 2 columns. The first is just a ‘1’; representing 1 towards the total of purchase orders that meet the condition. When summed up, this will give you the total.
The second column will be “IsLate”; either 1 (late) or 0 (not late).
To do that, you will probably need a subquery, embedded in the column, something like the following. But please note these are not real column names. Basically this is saying “if there exists an order line on this order which is late, then “1”, else “0”.)
(Case when exists (select 1 from purchase_order_line L where L.order_no = purchase_order.order_no L.wanted_delivery_date<sysdate and status = ‘Released’) then 1 else 0 end)
If you can get that working, then you will add a third column that combines these in a calculation (100 * Late / Total). When you do that, you need to be wary of the divide by zero error in Oracle. You can use a NULLIF command to prevent that error occurring.
Good luck!