Documente Academic
Documente Profesional
Documente Cultură
GO
-- 4. Afișați toate cărțile publicate la editura Polirom în iunie 2018 ordonate după titlu.
SELECT [Books].[Title],
[Books].[Published],
[Publishers].[Name] AS Publisher
FROM [Books]
JOIN [Publishers] ON [Publishers].[PublisherID]=[Books].[PublisherID]
WHERE DATEPART(MONTH FROM [Books].[Published])=6 AND
DATEPART(YEAR FROM [Books].[Published])=2018 AND
[Publishers].[Name]='Polirom'
ORDER BY [Books].[Title] ASC
GO
-- 5. Afișați toate cărțile din categoria Mister, publicate la editura Rao, ordonate descrescător după dată.
SELECT [Books].[Title],
[Genres].[Name] AS Genre,
[Publishers].[Name] AS Publisher,
[Books].[Published]
FROM [Books]
JOIN [Publishers] ON [Publishers].[PublisherID]=[Books].[PublisherID]
JOIN [Genres] ON [Genres].[GenreID]=[Books].[GenreID]
WHERE [Genres].[Name]='Mister' AND
[Publishers].[Name]='Rao'
ORDER BY [Books].[Published] DESC
GO
-- 9. Afișați numarul de cărți pentru fiecare autor. Se va afișa numele complet al autorului și numarul de
cărți.
SELECT [Authors].[FirstName] + ' ' + [Authors].[LastName] AS Author,
COUNT([Books].[BookID]) AS NumberOfBooks
FROM [Books]
JOIN [BooksAuthors] ON [BooksAuthors].[BookID]=[Books].[BookID]
JOIN [Authors] ON [Authors].[AuthorID]=[BooksAuthors].[AuthorID]
GROUP BY [Authors].[FirstName],
[Authors].[LastName]
GO
-- 13. Afișați cărțile Polițiste care au preț mai mare decât media prețurilor pentru cărțile Polițiste de la editura
Aldo Press.
DECLARE @MeanPrice float;
SET @MeanPrice = (SELECT AVG([Books].[Price])
FROM [Books]
JOIN [Genres] ON [Genres].[GenreID]=[Books].
[GenreID]
JOIN [Publishers] ON [Publishers].[PublisherID]=[Books].
[PublisherID]
WHERE [Genres].[Name]='Polițist' AND
[Publishers].[Name]='Aldo Press');
SELECT @MeanPrice;
SELECT [Books].[Title],
[Books].[Price],
[Genres].[Name] AS Genre,
[Publishers].[Name] AS Publisher
FROM [Books]
JOIN [Genres] ON [Genres].[GenreID]=[Books].[GenreID]
JOIN [Publishers] ON [Publishers].[PublisherID]=[Books].[PublisherID]
WHERE [Genres].[Name]='Polițist' AND
[Books].[Price]>@MeanPrice
GO
-- 14. Afișați primele 4 cărți ca volume avute în inventar pentru o anumită librărie.
SELECT TOP 5 [Books].[Title],
[Inventories].[NumberOfBooks],
[Libraries].[LibraryName]
FROM [Books]
JOIN [Inventories] ON [Inventories].[BookID]=[Books].[BookID]
JOIN [Libraries] ON [Libraries].[LibraryID]=[Inventories].[LibraryID]
WHERE [Libraries].[LibraryName]='Cărturești'
ORDER BY [Inventories].[NumberOfBooks] DESC
GO