salix/db/routines/vn/views/salesPersonSince.sql

17 lines
435 B
MySQL
Raw Normal View History

CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`salesPersonSince`
AS SELECT `b`.`workerFk` AS `workerFk`,
min(`b`.`started`) AS `started`
FROM (
(
`vn`.`business` `b`
JOIN `vn`.`worker` `w` ON(`w`.`id` = `b`.`workerFk`)
)
LEFT JOIN `vn`.`professionalCategory` `pc` ON(
`pc`.`id` = `b`.`workerBusinessProfessionalCategoryFk`
)
)
WHERE `pc`.`name` = 'Aux ventas'
GROUP BY `b`.`workerFk`