28 lines
631 B
MySQL
28 lines
631 B
MySQL
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||
|
SQL SECURITY DEFINER
|
||
|
VIEW `bs`.`horasSilla`
|
||
|
AS SELECT `wj`.`dated` AS `Fecha`,
|
||
|
`d`.`name` AS `Departamento`,
|
||
|
cast(sum(`wj`.`total`) AS decimal(10, 2)) AS `Horas`,
|
||
|
cast(
|
||
|
sum(
|
||
|
(`wj`.`total` + `wj`.`lunch`) * `wj`.`priceOrdinaryHour`
|
||
|
) AS decimal(10, 2)
|
||
|
) AS `Salarios`
|
||
|
FROM (
|
||
|
(
|
||
|
`vn`.`workerJourney` `wj`
|
||
|
JOIN `vn`.`business` `b` ON(`b`.`id` = `wj`.`businessFk`)
|
||
|
)
|
||
|
JOIN `vn`.`department` `d` ON(`d`.`id` = `b`.`departmentFk`)
|
||
|
)
|
||
|
WHERE `d`.`name` IN (
|
||
|
'CAMARA',
|
||
|
'ENCAJADO',
|
||
|
'PALETIZADORES',
|
||
|
'PRODUCCION',
|
||
|
'SACADORES'
|
||
|
)
|
||
|
GROUP BY `wj`.`dated`,
|
||
|
`d`.`name`
|