salix/db/routines/bs/views/VentasPorCliente.sql

15 lines
375 B
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `bs`.`VentasPorCliente`
AS SELECT `v`.`Id_Cliente` AS `Id_Cliente`,
round(sum(`v`.`importe`), 0) AS `VentaBasica`,
`t`.`year` AS `year`,
`t`.`month` AS `month`
FROM (
`vn2008`.`time` `t`
JOIN `bs`.`ventas` `v` ON(`v`.`fecha` = `t`.`date`)
)
GROUP BY `v`.`Id_Cliente`,
`t`.`year`,
`t`.`month`