1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-15 22:22:17 +03:00
Files
mariadb-columnstore-engine/mysql/queries/working_dml/misc/subupd001.sql
2016-01-06 14:08:59 -06:00

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;