sql >> Database >  >> RDS >> Oracle

Beginsituatie met orakel (subquery stuffs)

Probeer

select cust_fname, cust_lname
from
(select c.cust_fname, c.cust_lname
from customer c join salesorder so on so.so_custid = c.cust_id
join ITEM i on i.item_sonum = so.so_number
group by c.cust_fname, cust_lname
order by sum(i.item_qty) desc)
where rownum = 1

Hier is een sqlfiddle-demo

select cust_fname, cust_lname
from
(select c.cust_fname, c.cust_lname, rank() over (order by sum(i.item_qty) desc) rnk
from customer c join salesorder so on so.so_custid = c.cust_id
join ITEM i on i.item_sonum = so.so_number
group by c.cust_fname, cust_lname
)
where rnk = 1;



  1. wat is gematerialiseerde weergaven in orakel?

  2. Meerdere afbeeldingen uploaden met codeigniter

  3. PHP/MySQL:Selecteer locaties in de buurt van een bepaalde locatie uit DB

  4. Kan geen verbinding maken met externe MySQL-server