I made a simple query that checks for how much money a customer has bought singles:
SELECT k.voornaam || ' ' || k.familienaam as "Naam", sum( b.aantal * s.prijs) as "Omzet"
from bestellingen b
left join klanten k on k.klantid = b.klantid
left join singles s on s.singleid = b.singleid
where b.klantid = 12
group by k.voornaam,k.familienaam
this returns :
but I also need a third column named type customer
>
I have to find how good this revenue is in comparison with all the other customers
- the top 25% = I have to return ‘very good’
- 25 to 50% = return ‘good’
- 50 to 75% = return ‘average’
- 75% to 100% = ‘bad’
So I need the calculate the revenue for each customer and see how it compares to them.
How do i do this?
I can also use PL/SQL if this is better fit for this job as I am building an oracle project (apex).
thx 🙂
I assume Oracle Apex has the functionality underlying Oracle. You can do this with the percentile analytic function:
I’m assuming “omzet” means revenue.