WIP: feat: refs #8007 Added country salesByWeek #3190
|
@ -125,12 +125,11 @@ BEGIN
|
||||||
|
|
||||||
TRUNCATE salesByWeek;
|
TRUNCATE salesByWeek;
|
||||||
|
|
||||||
INSERT INTO salesByWeek (week, year, sales)
|
INSERT INTO salesByWeek (`year`, `week`, countryFk, sales)
|
||||||
SELECT t.week, t.year, SUM(v.importe + v.recargo) sales
|
SELECT YEAR(s.dated), WEEK(s.dated, 4), c.countryFk, SUM(s.amount)
|
||||||
FROM ventas v
|
FROM sale s
|
||||||
LEFT JOIN vn.time t ON t.dated = fecha
|
JOIN client c ON c.id = s.clientFk
|
||||||
GROUP BY t.week, t.year
|
GROUP BY YEAR(s.dated), WEEK(s.dated, 4), c.countryFk
|
||||||
ORDER BY t.week, t.year;
|
|
||||||
|
|
||||||
-- Indicador Ventas semana actual
|
-- Indicador Ventas semana actual
|
||||||
UPDATE indicators i
|
UPDATE indicators i
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
ALTER TABLE bs.salesByWeek
|
||||||
|
ADD countryFk mediumint(8) unsigned NOT NULL,
|
||||||
|
CHANGE `year` `year` int(11) NOT NULL FIRST,
|
||||||
|
CHANGE countryFk countryFk mediumint(8) unsigned NOT NULL AFTER week,
|
||||||
|
CHANGE sales total double DEFAULT NULL NULL,
|
||||||
|
ADD CONSTRAINT salesByWeek_country_FK FOREIGN KEY (countryFk) REFERENCES vn.country(id)
|
||||||
|
ON DELETE RESTRICT
|
||||||
|
ON UPDATE CASCADE;
|
Loading…
Reference in New Issue