1 create table [OrderLine] (Id int, OrderId int, ProductId int, Qty int, Status int);
2 create table [Product] (Id int, Name text, Price float);
4 select OrderId, count(*)
7 having count(*) > @cnt;
11 select sum(p.Price * ol.Qty) as Price
13 inner join Product p on ol.ProductId = p.Id
14 where ol.OrderId = @id;