All Downloads are FREE. Search and download functionalities are using the official Maven repository.

redshiftTableauQueries.10.sql Maven / Gradle / Ivy

SELECT "customer"."c_acctbal" AS "c_acctbal",
  "customer"."c_address" AS "c_address",
  "customer"."c_comment" AS "c_comment",
  "customer"."c_custkey" AS "c_custkey",
  "customer"."c_name" AS "c_name",
  "customer"."c_phone" AS "c_phone",
  "N1"."n_name" AS "n_name__nation1_",
  SUM(("lineitem"."l_extendedprice" * (1 - "lineitem"."l_discount"))) AS "sum_calculation_7060711085256495_ok"
FROM "tpch10g"."lineitem" "lineitem"
  INNER JOIN "tpch10g"."orders" "orders" ON ("lineitem"."l_orderkey" = "orders"."o_orderkey")
  INNER JOIN "tpch10g"."supplier" "supplier" ON ("lineitem"."l_suppkey" = "supplier"."s_suppkey")
  INNER JOIN "tpch10g"."customer" "customer" ON ("orders"."o_custkey" = "customer"."c_custkey")
  INNER JOIN "tpch10g"."nation" "N1" ON ("customer"."c_nationkey" = "N1"."n_nationkey")
  INNER JOIN (
  SELECT TOP 20 "customer"."c_custkey" AS "c_custkey",
    COUNT(1) AS "_tableau_join_flag",
    SUM(("lineitem"."l_extendedprice" * (1 - "lineitem"."l_discount"))) AS "___alias__0"
  FROM "tpch10g"."lineitem" "lineitem"
    INNER JOIN "tpch10g"."orders" "orders" ON ("lineitem"."l_orderkey" = "orders"."o_orderkey")
    INNER JOIN "tpch10g"."supplier" "supplier" ON ("lineitem"."l_suppkey" = "supplier"."s_suppkey")
    INNER JOIN "tpch10g"."customer" "customer" ON ("orders"."o_custkey" = "customer"."c_custkey")
    INNER JOIN "tpch10g"."nation" "N1" ON ("customer"."c_nationkey" = "N1"."n_nationkey")
  WHERE (((NOT ("supplier"."s_nationkey" IS NULL)) AND (((NOT ("N1"."n_regionkey" IS NULL)) AND (NOT ("lineitem"."l_partkey" IS NULL))) AND (NOT ("lineitem"."l_partkey" IS NULL)))) AND (("lineitem"."l_returnflag" = 'R') AND (("orders"."o_orderdate" >= DATEADD(MONTH,0,CAST(DATE_TRUNC( 'MONTH', CAST((TIMESTAMP '1993-10-01 00:00:00.000') AS TIMESTAMP WITHOUT TIME ZONE) ) AS TIMESTAMP WITHOUT TIME ZONE))) AND ("orders"."o_orderdate" < DATEADD(MONTH,3,CAST(DATE_TRUNC( 'MONTH', CAST((TIMESTAMP '1993-10-01 00:00:00.000') AS TIMESTAMP WITHOUT TIME ZONE) ) AS TIMESTAMP WITHOUT TIME ZONE))))))
  GROUP BY 1
  ORDER BY 3 DESC
) "t0" ON ("customer"."c_custkey" = "t0"."c_custkey")
WHERE (((NOT ("supplier"."s_nationkey" IS NULL)) AND (((NOT ("N1"."n_regionkey" IS NULL)) AND (NOT ("lineitem"."l_partkey" IS NULL))) AND (NOT ("lineitem"."l_partkey" IS NULL)))) AND (("lineitem"."l_returnflag" = 'R') AND (("orders"."o_orderdate" >= DATEADD(MONTH,0,CAST(DATE_TRUNC( 'MONTH', CAST((TIMESTAMP '1993-10-01 00:00:00.000') AS TIMESTAMP WITHOUT TIME ZONE) ) AS TIMESTAMP WITHOUT TIME ZONE))) AND ("orders"."o_orderdate" < DATEADD(MONTH,3,CAST(DATE_TRUNC( 'MONTH', CAST((TIMESTAMP '1993-10-01 00:00:00.000') AS TIMESTAMP WITHOUT TIME ZONE) ) AS TIMESTAMP WITHOUT TIME ZONE))))))
GROUP BY 1,
  2,
  3,
  4,
  5,
  6,
  7




© 2015 - 2025 Weber Informatics LLC | Privacy Policy