Created
May 24, 2016 06:35
-
-
Save xmorave2/cce20b14985937f67bfe2453a50193c1 to your computer and use it in GitHub Desktop.
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
SELECT i.itype, i.ccode, | |
(SELECT COUNT(*) FROM items i2 WHERE i2.dateaccessioned < @From AND i2.homebranch = @Library AND i2.ccode = i.ccode) AS "Počátek", | |
COUNT(*) AS "Přírůstek", | |
(SELECT COUNT(*) FROM items i3 WHERE i3.withdrawn_on BETWEEN @From AND @To AND i3.homebranch = @Library AND i3.ccode = i.ccode) AS "Úbytek", | |
(SELECT COUNT(*) FROM items i4 WHERE i4.dateaccessioned <= @To AND i4.homebranch = @Library AND i4.ccode = i.ccode) AS Konec | |
FROM items i | |
JOIN (SELECT @Library:=<<Knihovna|branches>> COLLATE utf8_unicode_ci, @From:=<<Od|date>>, @To:=<<Do|date>>) as vars | |
WHERE i.homebranch = @Library | |
AND i.dateaccessioned BETWEEN @From AND @To | |
GROUP BY i.itype, i.ccode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment