20 lines
595 B
SQL
20 lines
595 B
SQL
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
SQL SECURITY DEFINER
|
|
VIEW `bs`.`s1_ticketDetail`
|
|
AS SELECT `s`.`ticketFk` AS `ticketFk`,
|
|
cast(
|
|
sum(`s`.`price` * `s`.`quantity`) AS decimal(10, 2)
|
|
) AS `ticketAmount`,
|
|
COUNT(`s`.`id`) AS `ticketLines`,
|
|
cast(sum(`sv`.`volume`) AS decimal(10, 2)) AS `ticketM3`,
|
|
cast(`t`.`shipped` AS date) AS `shipped`
|
|
FROM (
|
|
(
|
|
`vn`.`ticket` `t`
|
|
JOIN `vn`.`sale` `s` ON(`s`.`ticketFk` = `t`.`id`)
|
|
)
|
|
JOIN `vn`.`saleVolume` `sv` ON(`sv`.`saleFk` = `s`.`id`)
|
|
)
|
|
WHERE `t`.`shipped` BETWEEN '2021-09-01' AND '2021-10-31 23:59'
|
|
GROUP BY `s`.`ticketFk`
|