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

17 lines
440 B
SQL

CREATE OR REPLACE DEFINER=`vn`@`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`.`description` = 'Aux ventas'
GROUP BY `b`.`workerFk`