24 lines
602 B
SQL
24 lines
602 B
SQL
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
SQL SECURITY DEFINER
|
|
VIEW `bi`.`v_ventas_contables`
|
|
AS SELECT `time`.`year` AS `year`,
|
|
`time`.`month` AS `month`,
|
|
cast(
|
|
sum(
|
|
`m`.`Cantidad` * `m`.`Preu` * (100 - `m`.`Descuento`) / 100
|
|
) AS decimal(10, 0)
|
|
) AS `importe`
|
|
FROM (
|
|
(
|
|
(
|
|
`vn`.`ticket` `t`
|
|
JOIN `bi`.`f_tvc` ON(`t`.`id` = `bi`.`f_tvc`.`Id_Ticket`)
|
|
)
|
|
JOIN `vn2008`.`Movimientos` `m` ON(`t`.`id` = `m`.`Id_Ticket`)
|
|
)
|
|
JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`shipped` AS date))
|
|
)
|
|
WHERE `t`.`shipped` >= '2014-01-01'
|
|
GROUP BY `time`.`year`,
|
|
`time`.`month`
|