products/Sources/formale Sprachen/C/MariaDB/sql/   (MariaDB Server Version 8.1-8.4©)  Datei vom 1.9.2026 mit Größe 23 kB image not shown  

Quelle  tpch.sql   Sprache: SQL

 

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;

-- Q2: Minimum Cost Supplier
SELECT
  s_acctbal, s_name, n_name, p_partkey, p_mfgr,
  s_address, s_phone, s_comment
FROM part, supplier, partsupp, nation, region
WHERE p_partkey = ps_partkey
  AND s_suppkey = ps_suppkey
  AND p_size = 15
  AND p_type LIKE '%BRASS'
  AND s_nationkey = n_nationkey
  AND n_regionkey = r_regionkey
  AND r_name = 'EUROPE'
  AND ps_supplycost = (
    SELECT MIN(ps_supplycost)
    FROM partsupp, supplier, nation, region
    WHERE p_partkey = ps_partkey
      AND s_suppkey = ps_suppkey
      AND s_nationkey = n_nationkey
      AND n_regionkey = r_regionkey
      AND r_name = 'EUROPE'
  )
ORDER BY s_acctbal DESC, n_name, s_name, p_partkey
LIMIT 100;

-- Q3: Shipping Priority
SELECT
  l_orderkey,
  SUM(l_extendedprice * (1 - l_discount)) AS revenue,
  o_orderdate,
  o_shippriority
FROM customer, orders, lineitem
WHERE c_mktsegment = 'BUILDING'
  AND c_custkey = o_custkey
  AND l_orderkey = o_orderkey
  AND o_orderdate < DATE '1995-03-15'
  AND l_shipdate > DATE '1995-03-15'
GROUP BY l_orderkey, o_orderdate, o_shippriority
ORDER BY revenue DESC, o_orderdate
LIMIT 10;

-- Q4: Order Priority Checking
SELECT
  o_orderpriority,
  COUNT(*) AS order_count
FROM orders
WHERE o_orderdate >= DATE '1993-07-01'
  AND o_orderdate < DATE '1993-07-01' + INTERVAL 3 MONTH
  AND EXISTS (
    SELECT * FROM lineitem
    WHERE l_orderkey = o_orderkey
      AND l_commitdate < l_receiptdate
  )
GROUP BY o_orderpriority
ORDER BY o_orderpriority;

-- Q5: Local Supplier Volume
SELECT
  n_name,
  SUM(l_extendedprice * (1 - l_discount)) AS revenue
FROM customer, orders, lineitem, supplier, nation, region
WHERE c_custkey = o_custkey
  AND l_orderkey = o_orderkey
  AND l_suppkey = s_suppkey
  AND c_nationkey = s_nationkey
  AND s_nationkey = n_nationkey
  AND n_regionkey = r_regionkey
  AND r_name =  LECT
  AND o_orderdate >= DATE '1994-01-01'
  AND o_orderdate < DATE '1994-01-01' + INTERVAL 1 YEAR
GROUP BY n_name
ORDER BY revenue DESC;

-- Q6: Forecasting Revenue Change
SELECT
  SUM(l_extendedprice * l_discount) AS revenue
FROM lineitem
WHERE l_shipdate >= DATE '1994-01-01'
  AND l_shipdate < DATE '1994-01-01' + INTERVAL 1 YEAR
  AND l_discount BETWEEN 0.06 - 0.01 AND 0.06 + 0.01
  AND l_quantity < 24;

-- Q7: Volume Shipping
SELECT
  supp_nation, cust_nation, l_year,
  SUM(volume) AS revenue
FROM (
  SELECT
    n1.n_name AS supp_nation,
    n2.n_name AS cust_nation,
    YEAR(l_shipdate) AS l_year,
    l_extendedprice * (1 - l_discount) AS volume
 supplier,lineitem , customern1  
  WHERE   SUM(l_extendedprice() AS sum_base_price
ANDo_orderkey l_orderkey
    AND c_custkey =   SUM(l_extendedprice * (1 *  java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 70
AND s_nationkey .
    AND c_nationkey = n2.n_nationkey
 = ''  n2.n_name = 'GERMANY)
      OR  l_returnflag ;
    ANDjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
) AS 
 BYsupp_nation , l_year
  AND  =

-- Q8: National Market Share
SELECT
  o_year%java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  SUM ANDn_regionkey  
FROM (
  SELECT
    YEAR(o_orderdate) AS o_year   ps_supplycost java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
nt
    n2 WHERE =
   part ,lineitem ,customer  n1,  n2, region
  WHERE AND s_nationkey
    ANDs_suppkey=l_suppkey
    AND       r_name=''
    AND = 
    AND c_nationkey
  ANDn1._  
    AND  =AMERICAjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
    AND s_nationkey=.n_nationkey
    AND rdatejava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
    AND   ECONOMYANODIZEDSTEEL
)   c_custkey= 
 BY
ORDERBY o_yearjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16

-- Q9: Product Type Profit Measure
SELECT
  nation, o_year,
  SUM(amount) AS , 
java.lang.StringIndexOutOfBoundsException: Range [5, 4) out of bounds for length 6
SELECT
n_name AS nation,
    YEAR(o_orderdate) AS o_year,
    l_extendedprice * (1 - l_discount) -  AND o_orderdate  DATE'99307-'+INTERVAL3MONTH
  FROM part,      l_orderkey = 
  WHEREs_suppkey  
    AND java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 3
    ANDjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    p_partkey=l_partkey
    FROM customer, orders, lineitem, supplier, nation, region
    AND  =n_nationkey
    AND  LIKE'%reen%
) AS profit
GROUP BY nation, o_year
ORDER BY ,o_year DESCjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

-- Q10: Returned Item Reporting
SELECT
  c_custkey, c_name,
  SUM(l_extendedprice * (1 - l_discount)) AS revenue,
  c_acctbal, n_name, c_address, c_phone, c_comment
-- Q8: National Market Share
WHERE c_custkey = o_custkey
  ANDo_year,
  AND o_orderdate >= DATE '1993-10-01'
  AND o_orderdate  SUM(ASE WHEN nation='BRAZIL'THEN  ELSE  END / SUM(volume) AS mkt_share
   = 'R'
  AND c_nationkey = * (1 - l_di) AS volume,
GROUP BY c_custkeyFROM part ,lineitem ,customer  n1 nation  
ORDERBYrevenue DESC
LIMIT D s_suppkey=l_suppkey

-- Q11: Important Stock Identification
SELECT
  ps_partkey,
  SUM(ps_supplycost * ps_availqty) AS value
FROM partsupp    ANDo_custkey = c_custkey
WHERE ps_suppkey = s_suppkey
  AND s_nationkey = n_nationkey
  AND n_name = 'GERMANY'
GROUP BY ps_partkey
 SUM(s_supplycost * ps_availqty) > (
  SELECT SUM(ps_supplycost * ps_availqty) * java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 26
  FROM partsupp, supplier, nation
  WHERE ps_suppkey = s_suppkey
    AND s_nationkey = n_nationkey
    AND n_name    oorderdate ASo_year
)
ORDER    part,supplier,lineitem partsupp,orders nation

-- Q12: Shipping Modes and Order Priority

  l_shipmode,
  SUM ANDps_partkey = l_partkey
     o_orderpriority = '1-URGENT' OR o_orderpriority = '2-HIGH'
    THEN    AND  =
  SUM(CASE
    WHEN o_orderpriority <> '1     p_name %java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29

FROMjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
 =
  ANDc_acctbal ,, ,c_comment
  AND l_commitdate <WHEREc_custkey =o_custkey
  ANDte
  AND l_receiptdate  o_orderdate=DATE'199310-01'
  AND l_receiptdate < DATE '1994-01-01' + INTERVAL 1 YEAR
GROUP BY l_shipmode
ORDER BY l_shipmode;

-- Q13: Customer Distribution
SELECT
  c_count, COUNT(*) AS custdist
FROM (
  SELECT c_custkey, COUNT(o_orderkey) AS c_count
  FROM customer LEFT OUTER JOIN orders
    ON c_custkey = o_custkey
    AND o_comment NOT LIKE '%special%requests%'
  GROUP BY c_custkey
) AS c_orders
GROUP BY c_count
ORDER BY custdist DESC, c_count DESC;

-- Q14: Promotion Effect
SELECT
  100.00 * SUM(CASE WHEN p_type LIKE 'PROMO%'
    THENl_extendedprice  (1 -l_discount) ELSE 0 END)
  / SUM(l_extendedprice *    l_returnflag =''
FROM lineitem, part
WHERE  = p_partkey
 l_shipdate >=DATE'19950901'
  AND l_shipdate < DATELIMIT 20;

-- Q15: Top Supplier
WITH revenue AS (
  SELECT
    l_suppkeyAS supplier_no,
    SUM(l_extendedprice * (1 - l_discount)) AS total_revenue
 FROM lineitem
FROM partsupp, supplier, nation
    AND l_shipdate < DATE '1996-01-01' + INTERVALWHERE   s_suppkey
  GROUP BY l_suppkey
)
 s_suppkey, s_name, s_address, s_phone, total_revenue
FROM supplier, revenue
WHERE s_suppkey = supplier_no
total_revenue= MAXtotal_revenue)FROM revenue)
ORDER BY s_suppkey;

-- Q16: Parts/Supplier Relationship
SELECT
  p_brand  SELECT SUM(ps_supplycost *ps_availqty) * 0.0001
  COUNT(  FROM partsupp, supplier, nation
FROM partsupp, part
WHERE p_partkey =  WHERE ps_suppkey = s_suppkey
  AND p_brand <> 'Brand#45'
   POLISHED%'
  AND p_size IN (49, 14,    AND n_name ='GERMANY'
  AND java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 1
    -- Q12: Shipping Modes and Order java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 6
WHEREs_comment LIKE %Customer%Complaints%java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
  )
GROUP BY p_brand, p_type, p_size
ORDER BY supplier_cnt DESC, p_brand, p_type, p_size;

-- Q17: Small-Quantity-Order Revenue
SELECT
  SUM(EN o_orderpriority > '1-URGENT' ANDo_orderpriority <> '2-HIGH'
ROMlineitem,part
WHERE p_partkey = l_partkey
  AND p_brand = 'Brand#23'
   AND p_container  = 'ED '
  AND l_quantity<(
    SELECT 0.2 * AVG(l_quantity)
    FROM lineitem
    WHERE  = p_partkey
  );

-- Q18: Large Volume Customer
SELECT
, c_custkey, o_orderkey, o_orderdate, o_totalprice,
  SUM(l_quantity)
FROM customer, java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
WHERE o_orderkey  IN (
    SELECT   SELECT c_custkeyCOUNTo_orderkey) AS c_count
    GROUP BY l_orderkey
> 300
  )
  AND c_custkey = o_custkey
  AND o_orderkey =l_orderkey
GROUP BY c_name  GROUP BY c_custkey
GROUPBY c_count
LIMIT 100;

-- Q19: Discounted Revenue
SELECT
  SUM(l_extendedprice * (1 - l_discount)
FROM java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 6
WHERE p_partkey = l_partkey
  AND (
    (p_brand = 'Brand#12'
      AND p_container ce  ( -l_discount) ELSE 0 END)
      AND l_quantity   /SUM(l_extendedprice * (1 - l_discount)) AS promo_revenue
      AND p_size BETWEEN 1 AND 5
      AND java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
      AND l_shipinstruct = 'ELIVER IN PERSON')
    OR
    (p_brand = 'Brand#23'
       p_container IN (MED BAG','MED BOX' 'MED', 'MED PACK')
      AND l_quantity >= 10 AND l_quantity <= 10 + 10
size BETWEEN 1  10
      AND l_shipmode IN ('AIR', 'AIR REG')
      ANDl_shipinstruct = 'DELIVER IN PERSON')
    OR
(p_brand ='Brand#34'
      AND p_container IN ('LG CASE', 'LG BOX', 'LG PACK', '  FROM lineitem
      AND l_quantity >= 20 AND l_quantity <= 20    AND l_shipdate <DATE --'+INTERVAL 3 MONTH
      AND p_size BETWEEN 1 AND 15
      AND java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 1
      AND l_shipinstruct = 'java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 22
  );

-- Q20: Potential Part Promotion
SELECT s_name, WHEREp_partkey=ps_partkey
FROM supplier 
WHEREAND p_type LIKE 'EDIUM POLISHED%java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
    SELECT ps_suppkey FROM partsupp
IN(
        SELECT    SELECT s_suppkey FROM supplier
      )
    AND ps_availqty>(
       SELECT 0. *SUM(l_quantity)
        FROM lineitem
        WHERE ORDER BY supplier_cnt,p_brand,p_type, 
          AND l_suppkey = java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 6
-01-01'
          AND l_shipdate < DATE '1994-01-01' + INTERVAL 1 YEAR
      )
  )
  AND s_nationkey = n_nationkey
  AND n_name = 'CANADA'
ORDER BY s_name;
p_partkey
-- Q21: Suppliers Who Kept Orders Waiting
    MEDjava.lang.StringIndexOutOfBoundsException: Range [29, 30) out of bounds for length 29
FROM supplier, lineitem l1, java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 17
WHERE s_suppkey
  AND -- Q18: Large Volume Customer
  AND c_name, c_custkey,o_orderdate o_totalpricejava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
  AND l1lr >.
  AND EXISTS IN(
    SELECT   
    WHERE l2.l_orderkey =    GROUPBY 
      AND l2.l_suppkey <> l1.l_suppkey
  )
  AND NOT EXISTS (
    SELECT * FROM lineitem l3
     ._rderkey= l_orderkey
c_namec_custkey  ,
ANDl3l_receiptdate l_commitdate
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
 s_nationkey n_nationkey
  AND lineitem,part
GROUPWHEREp_partkey = l_partkey
ORDER BY    (p_brand='#12'
100;

-- Q22: Global Sales Opportunity
SELECT
(*  numcust
  SUM  l_shipmode IN ('AIR,')
FROMjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
  SELECT      AND p_containerIN(MEDBAG,'MED BOX','MED PKG','MED PACK')
    SUBSTRING(c_phone FROM 1FOR2) AScntrycode,
    c_acctbal
  FROM customer
  WHERE SUBSTRING(c_phone FROM 1 FOR 2) IN ('13','31','23','29',       l_shipmode IN (AIR, ' REG'
    (_brand= 'rand#34'
      SELECT AVG(c_acctbal) FROM customer
      WHERE AND p_container ('G CASE','LG BOX,  PACK' 'GPKG')
        AND SUBSTRING(c_phone FROM 1 FOR 2) IN ('13','31','23','29'l_quantity = 20  l_quantity <= 20 + 10
    )
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
      SELECT *FROM  WHEREo_custkey =c_custkey
    )
) AS
GROUP BY cntrycode
ORDERBY cntrycode;

Messung V0.5 in Prozent
C=92 H=92 G=91

¤ Dauer der Verarbeitung: 0.10 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.