3
 SELECT   Sum(dbo.amzOrdersItem.price) as SubTotal, 
          Sum(dbo.amzOrdersItem.shippingPrice) as ShippingTotal, 
          Sum(dbo.amzOrdersItem.price) + Sum(dbo.amzOrdersItem.shippingPrice) as OrderTotal
 FROM     dbo.amzOrders INNER JOIN
          dbo.amzOrdersItem ON dbo.amzOrders.amzOrderId = dbo.amzOrdersItem.amzOrderId
 WHERE    dbo.amzOrders.id = '14818'
 GROUP BY dbo.amzOrders.id
4

2 に答える 2

0

クエリは次のようになります。

var query =
    from order in db.amzOrders
    join item in db.amzOrdersItems on order.amzOrderId equals item.amzOrderId
    where order.Id == 14818
    group item by order.Id into g
    select new
    {
        SubTotal = g.Sum(i => i.Price),
        ShippingTotal = g.Sum(i => i.ShippingPrice),
        OrderTotal = g.Sum(i => i.Price) + g.Sum(i => i.ShippingPrice),
    };

L2SQL クエリ プロバイダーがOrderTotal確実に行を正しく変換できるかどうかはわかりませんが、十分に単純であることを願っています。

于 2012-08-07T16:40:26.250 に答える