diff --git a/data/newqueerys.surrealql b/data/newqueerys.surrealql index 85c2663..f4b67a4 100644 --- a/data/newqueerys.surrealql +++ b/data/newqueerys.surrealql @@ -4,5 +4,27 @@ SELECT ingredient.designation AS Ingredient FROM RecipeContainsIngredients WHERE # get Ingredients where carbohydrates are lower than 40 SELECT designation FROM Ingredient WHERE carbohydrates <= 40; -# Find find user that ingredients +# find user that ingredients SELECT order.customer.first_name AS Name FROM OrderContainsIngredients WHERE ingredient.designation = 'Schalotte'; + +# Get total amount spend by each customer +SELECT string::concat(customer.first_name, ' ', customer.last_name) as customer, math::sum(invoice_amount) AS total_spent +FROM Order +GROUP BY customer; + +# Total number of deliver cost per supplyer + +SELECT supplier.name AS supplier, math::sum(delivery_cost) AS total_delivery_cost +FROM SupplierContainsIngredients +GROUP BY supplier; + + + + +# Stock low warning +DEFINE EVENT ingredient_stock_low ON TABLE Ingredient +WHEN $after.stock < 10 THEN ( + CREATE alert SET message = "Stock for ingredient " || $after.designation || " is low.", + ingredient_id = $value.id, + created_at = time::now() +);