Skip to content

Commit d697626

Browse files
committed
first commit of pawsql-jetbrains
0 parents  commit d697626

File tree

110 files changed

+8570
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+8570
-0
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 忽略编译输出
2+
out/
3+
build/
4+
5+
# 忽略 IDE 配置文件
6+
.idea/
7+
*.iml
8+
9+
# 忽略本地的 Gradle 缓存
10+
.gradle/
11+
12+
# 忽略构建输出
13+
build/
14+
15+
# 忽略日志文件
16+
*.log
17+
18+
# 忽略操作系统生成的文件
19+
.DS_Store
20+
21+
# 忽略其他临时文件
22+
*.tmp
23+
*.temp
24+
/src/main/resources/lib/
25+
/lib/
26+
/bin/

TPCH/1.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
select
2+
l_returnflag,
3+
l_linestatus,
4+
sum(l_quantity) as sum_qty,
5+
sum(l_extendedprice) as sum_base_price,
6+
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
7+
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
8+
avg(l_quantity) as avg_qty,
9+
avg(l_extendedprice) as avg_price,
10+
avg(l_discount) as avg_disc,
11+
count(*) as count_order
12+
from
13+
lineitem
14+
where
15+
l_shipdate <= date '2021-12-01' - interval '108' day
16+
group by
17+
l_returnflag,
18+
l_linestatus
19+
order by
20+
l_returnflag,
21+
l_linestatus;

TPCH/10.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
select
2+
c_custkey,
3+
c_name,
4+
sum(l_extendedprice * (1 - l_discount)) as revenue,
5+
c_acctbal,
6+
n_name,
7+
c_address,
8+
c_phone,
9+
c_comment
10+
from
11+
customer,
12+
orders,
13+
lineitem,
14+
nation
15+
where
16+
c_custkey = o_custkey
17+
and l_orderkey = o_orderkey
18+
and o_orderdate >= date '2021-08-01'
19+
and o_orderdate < date '2021-08-01' + interval '3' month
20+
and l_returnflag = 'R'
21+
and c_nationkey = n_nationkey
22+
group by
23+
c_custkey,
24+
c_name,
25+
c_acctbal,
26+
c_phone,
27+
n_name,
28+
c_address,
29+
c_comment
30+
order by
31+
revenue desc
32+
limit 20;

TPCH/11.sql

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
select
2+
ps_partkey,
3+
sum(ps_supplycost * ps_availqty) as value
4+
from
5+
partsupp ps,
6+
supplier,
7+
nation
8+
where
9+
ps_suppkey = s_suppkey
10+
and s_nationkey = n_nationkey
11+
and n_name = 'JAPAN'
12+
group by
13+
ps_partkey having
14+
sum(ps_supplycost * ps_availqty) > (
15+
select
16+
sum(ps_supplycost * ps_availqty) * 0.0001000000
17+
from
18+
partsupp,
19+
supplier,
20+
nation
21+
where
22+
ps_partkey = ps.ps_partkey and
23+
ps_partkey = s_suppkey
24+
and s_nationkey = n_nationkey
25+
and n_name = 'JAPAN'
26+
)
27+
order by
28+
value desc;

TPCH/12.sql

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
SELECT
2+
L_SHIPMODE,
3+
SUM(CASE
4+
WHEN O_ORDERPRIORITY = '1-URGENT'
5+
OR O_ORDERPRIORITY = '2-HIGH'
6+
THEN 1
7+
ELSE 0
8+
END) AS HIGH_LINE_COUNT,
9+
SUM(CASE
10+
WHEN O_ORDERPRIORITY <> '1-URGENT'
11+
AND O_ORDERPRIORITY <> '2-HIGH'
12+
THEN 1
13+
ELSE 0
14+
END) AS LOW_LINE_COUNT
15+
FROM
16+
ORDERS,
17+
LINEITEM
18+
WHERE
19+
O_ORDERKEY = L_ORDERKEY
20+
AND L_SHIPMODE IN ('RAIL', 'FOB')
21+
AND L_COMMITDATE < L_RECEIPTDATE
22+
AND L_SHIPDATE < L_COMMITDATE
23+
AND L_RECEIPTDATE >= DATE '2021-01-01'
24+
AND L_RECEIPTDATE < DATE '2021-01-01' + INTERVAL '1' YEAR
25+
GROUP BY
26+
L_SHIPMODE
27+
ORDER BY
28+
L_SHIPMODE;

TPCH/13.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
select
2+
c_count,
3+
count(*) as custdist
4+
from
5+
(
6+
select
7+
c_custkey,
8+
count(o_orderkey) as c_count
9+
from
10+
customer left outer join orders on
11+
c_custkey = o_custkey
12+
and o_comment not like '%pending%deposits%'
13+
group by
14+
c_custkey
15+
) c_orders
16+
group by
17+
c_count
18+
order by
19+
custdist desc,
20+
c_count desc;

TPCH/14.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
select
2+
100.00 * sum(case
3+
when p_type like 'PROMO%'
4+
then l_extendedprice * (1 - l_discount)
5+
else 0
6+
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue
7+
from
8+
lineitem,
9+
part
10+
where
11+
l_partkey = p_partkey
12+
and l_shipdate >= date '2021-12-01'
13+
and l_shipdate < date '2021-12-01' + interval '1' month;

TPCH/15.sql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
with revenue0 (supplier_no, total_revenue) as (
2+
select
3+
l_suppkey,
4+
sum(l_extendedprice * (1 - l_discount))
5+
from
6+
lineitem
7+
where
8+
l_shipdate >= date '2021-07-01'
9+
and l_shipdate < date '2021-07-01' + interval '3' month
10+
group by
11+
l_suppkey
12+
)
13+
select
14+
s_suppkey,
15+
s_name,
16+
s_address,
17+
s_phone,
18+
total_revenue
19+
from
20+
supplier,
21+
revenue0
22+
where
23+
s_suppkey = supplier_no
24+
and total_revenue = (
25+
select
26+
max(total_revenue)
27+
from
28+
revenue0
29+
)
30+
order by
31+
s_suppkey;

TPCH/16.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
select
2+
p_brand,
3+
p_type,
4+
p_size,
5+
count(distinct ps_suppkey) as supplier_cnt
6+
from
7+
partsupp,
8+
part
9+
where
10+
p_partkey = ps_partkey
11+
and p_brand <> 'Brand#34'
12+
and p_type not like 'LARGE BRUSHED%'
13+
and p_size in (48, 19, 12, 4, 41, 7, 21, 39)
14+
and ps_suppkey not in (
15+
select
16+
s_suppkey
17+
from
18+
supplier
19+
where
20+
s_comment like '%Customer%Complaints%'
21+
)
22+
group by
23+
p_brand,
24+
p_type,
25+
p_size
26+
order by
27+
supplier_cnt desc,
28+
p_brand,
29+
p_type,
30+
p_size;

TPCH/17.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
select
2+
sum(l_extendedprice) / 7.0 as avg_yearly
3+
from
4+
lineitem,
5+
part
6+
where
7+
p_partkey = l_partkey
8+
and p_brand = 'Brand#44'
9+
and p_container = 'WRAP PKG'
10+
and l_quantity < (
11+
select
12+
0.2 * avg(l_quantity)
13+
from
14+
lineitem
15+
where
16+
l_partkey = p_partkey
17+
);

0 commit comments

Comments
 (0)