30 lines
875 B
MySQL
30 lines
875 B
MySQL
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||
|
SQL SECURITY DEFINER
|
||
|
VIEW `vn`.`saleMistake_list__2`
|
||
|
AS SELECT `st`.`saleFk` AS `saleFk`,
|
||
|
`st`.`workerFk` AS `workerFk`,
|
||
|
concat(`w2`.`firstName`, ' ', `w2`.`lastName`) AS `sacador`,
|
||
|
`st`.`created` AS `created`,
|
||
|
concat(`w`.`firstName`, ' ', `w`.`lastName`) AS `revisador`,
|
||
|
`mt`.`description` AS `description`,
|
||
|
`sm`.`created` AS `controlled`
|
||
|
FROM (
|
||
|
(
|
||
|
(
|
||
|
(
|
||
|
(
|
||
|
`vn`.`saleTracking` `st`
|
||
|
JOIN `vn`.`worker` `w2` ON(`w2`.`id` = `st`.`workerFk`)
|
||
|
)
|
||
|
JOIN `vn`.`state` `s` ON(
|
||
|
`s`.`id` = `st`.`stateFk`
|
||
|
AND `s`.`code` IN ('PREVIOUS_PREPARATION', 'PREPARED', 'OK')
|
||
|
)
|
||
|
)
|
||
|
LEFT JOIN `vn`.`saleMistake` `sm` ON(`st`.`saleFk` = `sm`.`saleFk`)
|
||
|
)
|
||
|
LEFT JOIN `vn`.`mistakeType` `mt` ON(`mt`.`id` = `sm`.`typeFk`)
|
||
|
)
|
||
|
LEFT JOIN `vn`.`worker` `w` ON(`w`.`id` = `sm`.`userFk`)
|
||
|
)
|