日期:2014-05-17 浏览次数:21020 次
select * from (
select Product.*,(isnull(ProductIn.Number,0)-isnull(ProdcutOut.Numbers,0))as 库存量, row_number() over(order by Product.ID) RowNumber from Product
left join ProductIn
on Product.ID=ProductIn.PID
left join ProdcutOut on Product.ID=ProdcutOut.PID
)t where RowNumber>1 and RowNumber<=2
var query=from t1 in db.Table1
join t2 in db.Table2 on t1.t2Id equals t2.ID into lg1
from t2 in lg1.DefaultIfEmpty()
join t3 in db.Table3 on t1.t3Id equals t3.ID into lg2
from t3 in lg2.DefaultIfEmpty()
select new {t1.Id, t2ID=t2==null?0:t2.ID, t3Name=t3==null?"":t3.Name};