You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-15 22:22:17 +03:00
21 lines
395 B
SQL
21 lines
395 B
SQL
/*
|
|
* Sets c_nationkey to the orders count for the customer, then selects the 100 customers with the most orders.
|
|
*/
|
|
set autocommit=0;
|
|
|
|
update customer,
|
|
(select o_custkey as custkey, count(*) as ordercount
|
|
from orders
|
|
group by custkey) ords
|
|
set c_nationkey = ords.ordercount
|
|
where ords.custkey = c_custkey;
|
|
|
|
select c_custkey, c_nationkey
|
|
from customer
|
|
order by 2 desc, 1
|
|
limit 100;
|
|
|
|
rollback;
|
|
|
|
|