40 lines
1.7 KiB
MySQL
40 lines
1.7 KiB
MySQL
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||
|
SQL SECURITY DEFINER
|
||
|
VIEW `bs`.`lastIndicators`
|
||
|
AS SELECT `i`.`updated` AS `updated`,
|
||
|
`i`.`lastYearSales` AS `lastYearSales`,
|
||
|
`i`.`lastYearSales` - `yi`.`lastYearSales` AS `incLastYearSales`,
|
||
|
`i`.`totalGreuge` AS `totalGreuge`,
|
||
|
`i`.`totalGreuge` - `yi`.`totalGreuge` AS `incTotalGreuge`,
|
||
|
`i`.`latePaymentRate` AS `latePaymentRate`,
|
||
|
`i`.`latePaymentRate` - `yi`.`latePaymentRate` AS `incLatePaymentRate`,
|
||
|
`i`.`countEmployee` AS `countEmployee`,
|
||
|
`i`.`countEmployee` - `yi`.`countEmployee` AS `incCountEmployee`,
|
||
|
`i`.`averageMana` AS `averageMana`,
|
||
|
`i`.`averageMana` - `yi`.`averageMana` AS `incAverageMana`,
|
||
|
`i`.`bankingPool` AS `bankingPool`,
|
||
|
`i`.`bankingPool` - `yi`.`bankingPool` AS `incbankingPool`,
|
||
|
`i`.`lastMonthActiveClients` AS `lastMonthActiveClients`,
|
||
|
`i`.`lastMonthActiveClients` - `yi`.`lastMonthActiveClients` AS `incLastMonthActiveClients`,
|
||
|
`i`.`lastMonthLostClients` AS `lastMonthLostClients`,
|
||
|
`i`.`lastMonthLostClients` - `yi`.`lastMonthLostClients` AS `incLastMonthLostClients`,
|
||
|
`i`.`lastMonthNewClients` AS `lastMonthNewClients`,
|
||
|
`i`.`lastMonthNewClients` - `yi`.`lastMonthNewClients` AS `incLastMonthNewClients`,
|
||
|
`i`.`lastMonthWebBuyingRate` AS `lastMonthWebBuyingRate`,
|
||
|
`i`.`lastMonthWebBuyingRate` - `yi`.`lastMonthWebBuyingRate` AS `incLastMonthWebBuyingRate`,
|
||
|
`i`.`thisWeekSales` AS `thisWeekSales`,
|
||
|
`i`.`lastYearWeekSales` AS `lastYearWeekSales`
|
||
|
FROM (
|
||
|
`bs`.`indicators` `i`
|
||
|
JOIN `bs`.`indicators` `yi` ON(
|
||
|
`yi`.`updated` = (
|
||
|
SELECT max(`bs`.`indicators`.`updated`) + INTERVAL -1 DAY
|
||
|
FROM `bs`.`indicators`
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
WHERE `i`.`updated` = (
|
||
|
SELECT max(`bs`.`indicators`.`updated`)
|
||
|
FROM `bs`.`indicators`
|
||
|
)
|