在庫テーブルと在庫トランザクション テーブルを取得しました。インベントリのアイテムは、販売または自由に配布できます。各アイテムの販売合計、無料で配布された合計、および販売トランザクションで生成された収益を取得するクエリを作成したいと考えています。
次の行に沿った何か:
select i.Id,i.Title,
Sum(case when transactiontype=1 then s.MovedQuantity else 0 end) sold,
Sum(case when transactiontype=1 then s.MovedQuantity*s.UnitPrice else 0 end) Revenue,
Sum(case when transactiontype=0 then s.MovedQuantity else 0 end) distributed
From Inventory i,StockTransactions s
where i.Id=s.ItemId
group by i.Id,i.Title
これはlinq/lambdaでどのように行うことができますか?