 |
|
ผม LEFT OUTER JOIN พอจะ sum ทำไม่ได้เพราะว่ามีค่า Null อยากให้ค่า null เป็น 0 ทำยังไง ถ้าเป็น 0ได้ ผมว่าน่าจะ Sum ได้ |
|
 |
|
|
 |
 |
|
SELECT CASE MarkingDetail.StatusEditRequis WHEN 'False' THEN MarkingDetail.StatusEditRequis END AS TotalRequis, Stocks.CategoryName,
Stocks.PRODUCT, Stocks.GradName, Stocks.MATW, Stocks.MATL, Stocks.MATH, Stocks.MATT, Stocks.WeightSize, Stocks.Color, Stocks.UNIT,
Stocks.Remark, Stocks.Strong, MarkingDetail.StatusEditRequis, Stocks.Amount - MarkingDetail.Amount_Requis AS StockAmount_Requis,
Stocks.Amount, Sum(MarkingDetail.Amount_Requis)As Amount_Requis ' ตรงนี้จะ sum ทำไม่ได้เพราะว่ามีค่า Null อยากให้ค่า null เป็น 0 ทำยังไง ถ้าเป็น 0ได้ ผมว่าน่าจะ Sum ได้
FROM Stocks LEFT OUTER JOIN
MarkingDetail ON Stocks.PRODUCT = MarkingDetail.Product
ORDER BY Stocks.PRODUCT
Tag : .NET, VB.NET
|
|
 |
 |
 |
 |
Date :
2010-11-19 16:31:13 |
By :
chin |
View :
1558 |
Reply :
9 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
SELECT CASE MarkingDetail.StatusEditRequis WHEN 'False' THEN MarkingDetail.StatusEditRequis END AS TotalRequis, Stocks.CategoryName,
Stocks.PRODUCT, Stocks.GradName, Stocks.MATW, Stocks.MATL, Stocks.MATH, Stocks.MATT, Stocks.WeightSize, Stocks.Color, Stocks.UNIT,
Stocks.Remark, Stocks.Strong, MarkingDetail.StatusEditRequis, Stocks.Amount - MarkingDetail.Amount_Requis AS StockAmount_Requis,
Stocks.Amount, ISNULL(Sum(MarkingDetail.Amount_Requis),0) As Amount_Requis ' ลองใส่ ISNULL แล้วได้ไหม
FROM Stocks LEFT OUTER JOIN
MarkingDetail ON Stocks.PRODUCT = MarkingDetail.Product
ORDER BY Stocks.PRODUCT
|
 |
 |
 |
 |
Date :
2010-11-19 17:04:04 |
By :
watcharop |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Sum(ISNULL(MarkingDetail.Amount_Requis,0)) As Amount_Requis
|
 |
 |
 |
 |
Date :
2010-11-20 10:34:06 |
By :
... |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
isnull(Filed_name,0)
|
 |
 |
 |
 |
Date :
2010-11-20 11:21:40 |
By :
nooknoname |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
MarkingDetail.Amount_Requis แต่ตัวนี้ดูก่อนครับ ว่าได้ค่าอะไร แล้วก็ค่าของ MarkingDetail.Amount_Requis มี่ค่าเป็น null หรือป่าวครับ
|
 |
 |
 |
 |
Date :
2010-11-24 20:12:51 |
By :
kanchen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
nvl(Amount_Requis ,0) as test
|
 |
 |
 |
 |
Date :
2010-11-25 12:38:50 |
By :
xcom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบความคิดเห็นที่ : 8 เขียนโดย : xcom เมื่อวันที่ 2010-11-25 12:38:50
รายละเอียดของการตอบ ::
SELECT CASE MarkingDetail.StatusEditRequis WHEN 'False' THEN ISNULL(MarkingDetail.Amount_Requis, 0) END AS Total, Stocks.PRODUCT,
Stocks.GradName, Stocks.MATW, Stocks.MATL, Stocks.MATH, Stocks.MATT, Stocks.WeightSize, Stocks.Color, Stocks.UNIT, Stocks.Remark,
Stocks.Strong, SUM(ISNULL(Stocks.Amount - MarkingDetail.Amount_Requis, 0)) AS StockAmount_Requis, Stocks.Amount,
ISNULL(MarkingDetail.Amount_Requis, 0) AS Amount_Requis
FROM Stocks LEFT OUTER JOIN
MarkingDetail ON Stocks.PRODUCT = MarkingDetail.Product
GROUP BY Stocks.CategoryName, Stocks.PRODUCT, Stocks.GradName, Stocks.MATW, Stocks.MATL, Stocks.MATH, Stocks.MATT, Stocks.WeightSize,
Stocks.Color, Stocks.UNIT, Stocks.Remark, Stocks.Strong, Stocks.Amount, MarkingDetail.StatusEditRequis, MarkingDetail.Amount_Requis
ORDER BY Stocks.PRODUCT
ยังมีค่า NULL อยู่ ตัวอื่น คำสั่งเดียวกันเป็น 0 งง
|
 |
 |
 |
 |
Date :
2010-11-27 17:02:35 |
By :
chin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|