Created
July 31, 2021 17:48
-
-
Save bbrt3/e1a4b83ca66f8a1a6cb054f55a819e98 to your computer and use it in GitHub Desktop.
SQL Magic
This file contains hidden or 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 a.Id, COUNT(b.Title) AS BookCount FROM BooksDB.dbo.Books AS b JOIN BooksDB.dbo.Authors AS a ON b.AuthorId = a.Id GROUP BY a.Id | |
UPDATE BooksDB.dbo.Fun SET Value = (SELECT COUNT(b.Title) AS BookCount FROM BooksDB.dbo.Books AS b JOIN BooksDB.dbo.Authors AS a ON b.AuthorId = a.Id GROUP BY a.Id) | |
ID AUTORA LICZBA_KSIĄŻEK (ZLICZONA W QUERY) AS LQ LICZBA_KSIĄŻEK (ZAPISANA W TABELI) AS LT | |
------------------------------------------------- | |
JOIN STATS ON LT.ID = LQ.ID | |
--------------------------------------------- | |
UPDATE STATS SET VALUE = LICZBA_KSIĄŻEK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment