Run a Reporting Query
This example reporting query (Q1) from the DBT-3 benchmark asks for the amount of business that was billed, shipped, and returned in the last quarter of 1998.
SELECT l_returnflag, l_linestatus, sum(l_quantity) as sum_qty,
sum(l_extendedprice) as sum_base_price,
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
avg(l_quantity) as avg_qty, avg(l_extendedprice) as avg_price,
avg(l_discount) as avg_disc, count(*) as count_order
FROM lineitem
WHERE l_shipdate <= date '1998-12-01' - interval '90' day
GROUP BY l_returnflag, l_linestatus
ORDER BY l_returnflag, l_linestatus;\g
Executing . . .
returnflag linestatus sum_qty sum_base_price sum_disc_price
A F 1132676958 1698421699729.99 1613502554023.1240
N F 29581022 44353456023.61 42135855268.9589
N O 2230403478 3344516955134.66 3177286529933.9344
R F 1132872903 1698719719123.67 1613789096673.0512
sum_charge avg_qty avg_price avg_dis count_order
1678049479312.961024 25.4 38236.375 0.050 44419004
43821835543.370384 25.5 38270.478 0.049 1158947
3304387310370.192384 25.4 38235.736 0.049 87470970
1678345906004.148224 25.5 38243.421 0.049 44418612
(4 rows)
Last modified date: 06/28/2024