mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-04-18 21:44:02 +03:00
44 lines
680 B
SQL
44 lines
680 B
SQL
-- $ID$
|
|
-- TPC-H/TPC-R Top Supplier Query (Q15)
|
|
-- Functional Query Definition
|
|
-- Approved February 1998
|
|
:x
|
|
create view revenue:s (supplier_no, total_revenue) as
|
|
select
|
|
l_suppkey,
|
|
sum(l_extendedprice * (1 - l_discount))
|
|
from
|
|
lineitem
|
|
where
|
|
l_shipdate >= date ':1'
|
|
and l_shipdate < date ':1' + interval '3' month
|
|
group by
|
|
l_suppkey;
|
|
|
|
:o
|
|
select
|
|
s_suppkey,
|
|
s_name,
|
|
s_address,
|
|
s_phone,
|
|
total_revenue
|
|
from
|
|
supplier,
|
|
revenue:s
|
|
where
|
|
s_suppkey = supplier_no
|
|
and total_revenue = (
|
|
select
|
|
max(total_revenue)
|
|
from
|
|
revenue:s
|
|
)
|
|
order by
|
|
s_suppkey;
|
|
|
|
drop view revenue:s;
|
|
:n -1
|
|
|
|
-- Not sure about the creat view part, but skipping ahead to the
|
|
-- select...
|