Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; | ||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; | ||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES'; | ||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Placeholder table for view `Comulative` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `Comulative` (`owner` INT, `date` INT, `summary` INT); | ||
|
||
-- ----------------------------------------------------- | ||
-- View `Comulative` | ||
-- ----------------------------------------------------- | ||
DROP VIEW IF EXISTS `Comulative` ; | ||
DROP TABLE IF EXISTS `Comulative`; | ||
DELIMITER $$ | ||
CREATE OR REPLACE VIEW `Comulative` AS | ||
SELECT t.owner, t.date, SUM( t.value ) as sum , ( | ||
SELECT t.owner, t.date, ( | ||
SELECT SUM( x.value ) | ||
FROM Money x | ||
WHERE x.id <= t.id AND x.owner = t.owner | ||
WHERE x.date <= t.date AND x.owner = t.owner | ||
) AS summary | ||
FROM Money t | ||
GROUP BY date, owner | ||
ORDER BY t.id | ||
$$ | ||
DELIMITER ; | ||
|
||
; | ||
|
||
|
||
SET SQL_MODE=@OLD_SQL_MODE; | ||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; | ||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; | ||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; | ||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; | ||
|
||
|
||
-- ----------------------------------------------------- | ||
-- Placeholder table for view `Comulative` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `Comulative` (`owner` INT, `date` INT, `summary` INT); | ||
|
||
-- ----------------------------------------------------- | ||
-- Placeholder table for view `Perday` | ||
-- ----------------------------------------------------- | ||
CREATE TABLE IF NOT EXISTS `Perday` (`id` INT, `category` INT, `owner` INT, `subcategory` INT, `title` INT, `date` INT, `value` INT, `description` INT, `sum` INT); | ||
|
||
-- ----------------------------------------------------- | ||
-- View `Comulative` | ||
-- ----------------------------------------------------- | ||
DROP VIEW IF EXISTS `Comulative` ; | ||
DROP TABLE IF EXISTS `Comulative`; | ||
DELIMITER $$ | ||
CREATE OR REPLACE VIEW `Comulative` AS | ||
SELECT t.owner, t.date, ( | ||
SELECT SUM( x.value ) | ||
FROM Money x | ||
WHERE x.id <= t.id AND x.owner = t.owner | ||
) AS summary | ||
FROM Money t | ||
GROUP BY date, owner | ||
ORDER BY t.id | ||
$$ | ||
DELIMITER ; | ||
|
||
; | ||
|
||
-- ----------------------------------------------------- | ||
-- View `Perday` | ||
-- ----------------------------------------------------- | ||
DROP VIEW IF EXISTS `Perday` ; | ||
DROP TABLE IF EXISTS `Perday`; | ||
DELIMITER $$ | ||
CREATE OR REPLACE VIEW `Perday` AS | ||
SELECT m.*, sum(m.value) as sum from Money m group by `date` | ||
$$ | ||
DELIMITER ; | ||
|
||
; | ||
|
||
|
||
SET SQL_MODE=@OLD_SQL_MODE; | ||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; | ||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; |
Binary file not shown.
Binary file not shown.