sql >> Database teknologi >  >> RDS >> Oracle

Opstartssituation med oracle (underforespørgsel)

Prøv

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

Her er en 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. Unicode Encode Fejl "latin-1" codec kan ikke kode tegnet "\u2019"

  2. Hvordan matcher man ikke null + ikke tom?

  3. Kø i OneWay WCF-meddelelser ved hjælp af Windows Service og SQL Server

  4. Anbringelse af markørdata i et array