Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT "product_id",
  2.        "stock_product"."id",
  3.        "stock_id",
  4.        "price",
  5.        "cu_price",
  6.        "amount",
  7.        "multiplicity",
  8.        "stock_product"."date_modified",
  9.        "_cross_type",
  10.        "manufacturer"."name"
  11. FROM (SELECT "stock_product".*,
  12.              ceil(price * (1 + (COALESCE(CASE
  13.                                              WHEN (SELECT "surcharge_percent"
  14.                                                    FROM "customer_group_surcharge_range"
  15.                                                    WHERE (("customer_group_surcharge_range"."stock_id" = stock_product.stock_id) OR
  16.                                                           ("customer_group_surcharge_range"."stock_id" IS NULL))
  17.                                                      AND ("customer_group_surcharge_range"."customer_group_id" = 19)
  18.                                                      AND (CEIL("stock_product".price) BETWEEN min_price AND max_price)
  19.                                                    ORDER BY "stock_id", "min_price"
  20.                                                    LIMIT 1) < -99 THEN 1
  21.                                              ELSE (SELECT "surcharge_percent"
  22.                                                    FROM "customer_group_surcharge_range"
  23.                                                    WHERE (("customer_group_surcharge_range"."stock_id" = stock_product.stock_id) OR
  24.                                                           ("customer_group_surcharge_range"."stock_id" IS NULL))
  25.                                                      AND ("customer_group_surcharge_range"."customer_group_id" = 19)
  26.                                                      AND (CEIL("stock_product".price) BETWEEN min_price AND max_price)
  27.                                                    ORDER BY "stock_id", "min_price"
  28.                                                    LIMIT 1) END, 21) / 100.0))) AS "cu_price",
  29.              CASE
  30.                  WHEN product.id = 427082 THEN 0
  31.                  WHEN manufacturer_id = 2380 THEN 0
  32.                  ELSE cross_type + 1
  33.                  END                                                            AS "_cross_type"
  34.       FROM (
  35.           SELECT *
  36.             FROM "stock_product"
  37.             WHERE ("stock_product"."product_id" IN
  38.                    (208748, 427082, 735727, 796608, 797704, 844633, 1172790, 1183102, 1283524, 1382304, 1529888,
  39.                     1704050, 1741991, 1870037, 2081793, 2495048, 2504768, 2818736, 2842036, 2943893, 2966302, 3061825,
  40.                     4099834, 4190072, 4215283, 4866023, 5064121, 5070751, 6157929, 6370129, 6624134, 6641479))
  41.               AND ("amount" > 0)
  42.               AND (EXISTS(SELECT 1 FROM "stock" WHERE ("act" = 1) AND ("id" = "stock_product".stock_id)))
  43.               AND (NOT EXISTS(SELECT 1
  44.                               FROM "disabled_stock_to_customer_group"
  45.                               WHERE ("customer_group_id" = 19)
  46.                                 AND ("stock_id" = "stock_product".stock_id)))
  47.           ) "stock_product"
  48.                INNER JOIN "product" ON "stock_product"."product_id" = "product"."id"
  49.                INNER JOIN "crosses" ON "product"."id" = "crosses"."associative") "stock_product"
  50.          LEFT JOIN "product" ON "stock_product"."product_id" = "product"."id"
  51.          LEFT JOIN "manufacturer" ON "product"."manufacturer_id" = "manufacturer"."id"
  52. WHERE cu_price between '739' and '2122'
  53. GROUP BY "product_id", "stock_product"."id", "stock_id", "price", "cu_price", "amount", "multiplicity",
  54.          "stock_product"."date_modified", "_cross_type", "manufacturer"."name"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement