Skip to content

Instantly share code, notes, and snippets.

@FromMeloriWithLove
Last active July 3, 2023 12:21
Show Gist options
  • Save FromMeloriWithLove/fa7b8345afb23d0f5fefc17fd8a63cd1 to your computer and use it in GitHub Desktop.
Save FromMeloriWithLove/fa7b8345afb23d0f5fefc17fd8a63cd1 to your computer and use it in GitHub Desktop.
2.
SELECT c.name, SUM(price * quantity) AS TotalSales
FROM Category c
JOIN Product p ON c.id = p.id_category
WHERE c.name IN ('Мясные', 'Хлебо-булочные')
GROUP BY c.name
3.
SELECT s.name, MIN(d.price * d.quantity) AS Minn
FROM Delivery d
JOIN Supplier s ON s.id = d.id_supplier
WHERE date_of_delivery BETWEEN DATEADD(MONTH, -30, GETDATE()) AND GETDATE()
GROUP BY s.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment