7525-devToTest #2542
|
@ -23,7 +23,6 @@ proc: BEGIN
|
||||||
* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT)
|
* @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT)
|
||||||
* @return tmp.comparative
|
* @return tmp.comparative
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DECLARE vDayRangeStart DATE;
|
DECLARE vDayRangeStart DATE;
|
||||||
DECLARE vDayRangeEnd DATE;
|
DECLARE vDayRangeEnd DATE;
|
||||||
DECLARE w1, w2, w3, w4, w5, w6, w7 INT;
|
DECLARE w1, w2, w3, w4, w5, w6, w7 INT;
|
||||||
|
@ -150,14 +149,14 @@ proc: BEGIN
|
||||||
SUM(IF(c.timePeriod = y7, c.price, 0)) lprice7
|
SUM(IF(c.timePeriod = y7, c.price, 0)) lprice7
|
||||||
FROM tmp.itemInventory ai
|
FROM tmp.itemInventory ai
|
||||||
JOIN comparative c ON c.itemFk = ai.id
|
JOIN comparative c ON c.itemFk = ai.id
|
||||||
JOIN warehouse w on w.id = c.warehouseFk
|
JOIN warehouse w ON w.id = c.warehouseFk
|
||||||
JOIN tTable wt ON c.timePeriod = wt.ly
|
JOIN tTable wt ON c.timePeriod = wt.ly
|
||||||
WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
|
WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
AND (vCountryFk IS NULL OR c.countryFk = vCountryFk)
|
AND (vCountryFk IS NULL OR c.countryFk = vCountryFk)
|
||||||
GROUP BY ai.id;
|
GROUP BY ai.id;
|
||||||
|
|
||||||
-- Genera una tabla con los datos de hace DOS años.
|
-- Genera una tabla con los datos de hace 2 años
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tTwoYearsAgo
|
CREATE OR REPLACE TEMPORARY TABLE tTwoYearsAgo
|
||||||
(KEY (tItemFk))
|
(KEY (tItemFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
@ -178,7 +177,7 @@ proc: BEGIN
|
||||||
SUM(IF(c.timePeriod = z7, c.price, 0)) vlprice7
|
SUM(IF(c.timePeriod = z7, c.price, 0)) vlprice7
|
||||||
FROM tmp.itemInventory ai
|
FROM tmp.itemInventory ai
|
||||||
JOIN comparative c ON c.itemFk = ai.id
|
JOIN comparative c ON c.itemFk = ai.id
|
||||||
JOIN warehouse w on w.id = c.warehouseFk
|
JOIN warehouse w ON w.id = c.warehouseFk
|
||||||
JOIN tTable wt ON c.timePeriod = wt.zy
|
JOIN tTable wt ON c.timePeriod = wt.zy
|
||||||
WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
|
WHERE (vWarehouseFk IS NULL OR vWarehouseFk = c.warehouseFk)
|
||||||
AND w.isComparative
|
AND w.isComparative
|
||||||
|
@ -229,7 +228,7 @@ proc: BEGIN
|
||||||
) t
|
) t
|
||||||
GROUP BY t.itemFk;
|
GROUP BY t.itemFk;
|
||||||
|
|
||||||
-- Genera la tabla con la comparativa.
|
-- Genera la tabla con la comparativa
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.comparative
|
CREATE OR REPLACE TEMPORARY TABLE tmp.comparative
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT it.subName productor,
|
SELECT it.subName productor,
|
||||||
|
|
Loading…
Reference in New Issue