SHARE
TWEET

Untitled

a guest Sep 2nd, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.       GENERICO,
  3.       DESCRIPCION,
  4.       ARTICULO,
  5.       COLOR,
  6.       TALLE,
  7.       DOC_ID,
  8.       DOC_NUMERO,
  9.       DOC_FECHA,
  10.       SUM(CANTIDAD) AS CANTIDAD
  11.     FROM
  12.     (
  13.       SELECT
  14.         ARTICULOS.ARTICU_ID AS GENERICO,
  15.         ITEMS.ARTICU_ID AS ARTICULO,
  16.         COLORES.DENOMINACION AS COLOR,
  17.         TALLES.DENOMINACION AS TALLE,
  18.         ITEMS.DOC_ID AS DOC_ID,
  19.         SUM(CANTIDAD) AS CANTIDAD
  20.       FROM
  21.         MASEFER.DOCUMENTOS_ITEMS ITEMS
  22.         LEFT JOIN MASEFER.ARTICULOS ARTICULOS ON ARTICULOS.ID = ITEMS.ARTICU_ID
  23.         LEFT JOIN MASEFER.ARTICULOS_COLOR COLORES ON ARTICULOS.COLOR = COLORES.ID
  24.         LEFT JOIN MASEFER.TALLES TALLES ON ARTICULOS.TALLE_ID = TALLES.ID
  25.         AND ARTICULOS.SUBFAMILIA_FAMILIAS_ID = TALLES.FAMILIA_ID
  26.       WHERE
  27.         DOC_ID IN (
  28.           SELECT
  29.             DOC_ITEMS_DOC_ID AS DOC_ID
  30.           FROM
  31.             MASEFER.ITEMRELA
  32.           WHERE
  33.             DOC_ITEMS_HIJO_DOC_ID IN (
  34.               SELECT
  35.                 ID_DOCUMENTO_ARTICULO AS DOC_ITEMS_HIJO_DOC_ID
  36.               FROM
  37.                 MASEFER.TALLER_ARTICULOS
  38.               WHERE
  39.                 ID_ARTICULO = ${tareaId}
  40.             )
  41.         )
  42.       GROUP BY
  43.         ITEMS.ARTICU_ID,
  44.         ARTICULOS.ARTICU_ID,
  45.         COLORES.DENOMINACION,
  46.         TALLES.DENOMINACION,
  47.         ITEMS.DOC_ID
  48.       ) ARTICULOS_DE_TAREA
  49.       LEFT JOIN
  50.         (
  51.           SELECT
  52.             DOCUMENTOS.NUMERO AS DOC_NUMERO,
  53.             DOCUMENTOS.FECHA AS DOC_FECHA,
  54.             DOCUMENTOS.ID
  55.           FROM MASEFER.DOCUMENTOS
  56.         ) DOCS_DETALLES
  57.         ON DOCS_DETALLES.ID=ARTICULOS_DE_TAREA.DOC_ID
  58.       INNER JOIN
  59.       (
  60.         SELECT DISTINCT
  61.           ARTICU_ID AS ID,
  62.           DENOMINACION AS DESCRIPCION
  63.         FROM MASEFER.ARTICULOS ARTICULOS
  64.         WHERE (
  65.           ARTICULOS.ID = ARTICULOS.ARTICU_ID OR
  66.           ARTICULOS.ARTICU_ID IS NULL
  67.         )
  68.       ) ARTICULOS_GENERICOS
  69.         ON
  70.           ARTICULOS_DE_TAREA.GENERICO = ARTICULOS_GENERICOS.ID
  71.     GROUP BY
  72.       ARTICULO,
  73.       COLOR,
  74.       TALLE,
  75.       GENERICO,
  76.       DESCRIPCION,
  77.       DOC_NUMERO,
  78.       DOC_FECHA,
  79.       DOC_ID
  80.     ORDER BY
  81.       GENERICO,
  82.       ARTICULO,
  83.       COLOR,
  84.       TALLE,
  85.       DOC_ID
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top