NinjaTurtle
08-13-2004, 04:00 AM
Dear,
How to filter the OSQTY when it is equal to 0? when i add the vTable1.Qty - vTable3.Qty <>0 at Where Clause it will get wrong sorting of the [Delivered Qty]??? dunno why?
How to filter record in SQL statement(MS SQL 2000), or i can only use ASP to filter it?
sample record in database:
SO ID, Customer ID, Outlet ID, WH ID, Product ID, UoM, Unit Price, Ordered Qty, DO ID, Delivered Qty, OSQTY
S0010, ACT111, PJ, WH1, AB36U, rll, 71.3, 24, 60312/DO, 24, 0
S0011, ACT111, PJ, WH1, AB236U, rll, 71.3, 4, 60313/DO, 3, 1
SELECT TOP 100 PERCENT vTable.[SO ID], vTable.[Customer ID], vTable1.[Outlet ID], vTable1.[Warehouse ID], vTable1.[Product ID], vTable1.UoM,
vTable1.[Unit Price], vTable1.Qty AS [Ordered Qty], vTable2.[DO ID], vTable3.Qty AS [Delivered Qty], vTable4.Currency, vTable5.Discount, vTable5.Tax,
vTable1.Qty - vTable3.Qty AS OSQTY
FROM dbo.t_MYDMS1101SalesOrder_M vTable INNER JOIN
dbo.t_MYDMS1101SalesOrder_D vTable1 ON vTable.[SO ID] = vTable1.[SO ID] INNER JOIN
dbo.t_MYDMS1102DeliveryOrder_M vTable2 ON vTable1.[SO ID] = vTable2.[SO ID] INNER JOIN
dbo.t_MYDMS1102DeliveryOrder_D vTable3 ON vTable2.[DO ID] = vTable3.[DO ID] INNER JOIN
dbo.t_MYDMS1101Products vTable5 ON vTable1.[Product ID] = vTable5.[Product ID] LEFT OUTER JOIN
dbo.t_MYDMS1101Customers vTable4 ON vTable.[Customer ID] = vTable4.[Customer ID]
WHERE (vTable.Status = 'Yes')
GROUP BY vTable.[Customer ID], vTable.[SO ID], vTable.[Date], vTable1.[Due Date], vTable1.[Outlet ID], vTable1.[Warehouse ID], vTable1.[Product ID],
vTable1.UoM, vTable1.[Unit Price], vTable1.Qty, vTable2.[SO ID], vTable2.[DO ID], vTable3.[DO ID], vTable3.Qty, vTable4.Currency, vTable5.Discount,
vTable5.Tax
ORDER BY vTable.[Customer ID], vTable.[SO ID]
How to filter the OSQTY when it is equal to 0? when i add the vTable1.Qty - vTable3.Qty <>0 at Where Clause it will get wrong sorting of the [Delivered Qty]??? dunno why?
How to filter record in SQL statement(MS SQL 2000), or i can only use ASP to filter it?
sample record in database:
SO ID, Customer ID, Outlet ID, WH ID, Product ID, UoM, Unit Price, Ordered Qty, DO ID, Delivered Qty, OSQTY
S0010, ACT111, PJ, WH1, AB36U, rll, 71.3, 24, 60312/DO, 24, 0
S0011, ACT111, PJ, WH1, AB236U, rll, 71.3, 4, 60313/DO, 3, 1
SELECT TOP 100 PERCENT vTable.[SO ID], vTable.[Customer ID], vTable1.[Outlet ID], vTable1.[Warehouse ID], vTable1.[Product ID], vTable1.UoM,
vTable1.[Unit Price], vTable1.Qty AS [Ordered Qty], vTable2.[DO ID], vTable3.Qty AS [Delivered Qty], vTable4.Currency, vTable5.Discount, vTable5.Tax,
vTable1.Qty - vTable3.Qty AS OSQTY
FROM dbo.t_MYDMS1101SalesOrder_M vTable INNER JOIN
dbo.t_MYDMS1101SalesOrder_D vTable1 ON vTable.[SO ID] = vTable1.[SO ID] INNER JOIN
dbo.t_MYDMS1102DeliveryOrder_M vTable2 ON vTable1.[SO ID] = vTable2.[SO ID] INNER JOIN
dbo.t_MYDMS1102DeliveryOrder_D vTable3 ON vTable2.[DO ID] = vTable3.[DO ID] INNER JOIN
dbo.t_MYDMS1101Products vTable5 ON vTable1.[Product ID] = vTable5.[Product ID] LEFT OUTER JOIN
dbo.t_MYDMS1101Customers vTable4 ON vTable.[Customer ID] = vTable4.[Customer ID]
WHERE (vTable.Status = 'Yes')
GROUP BY vTable.[Customer ID], vTable.[SO ID], vTable.[Date], vTable1.[Due Date], vTable1.[Outlet ID], vTable1.[Warehouse ID], vTable1.[Product ID],
vTable1.UoM, vTable1.[Unit Price], vTable1.Qty, vTable2.[SO ID], vTable2.[DO ID], vTable3.[DO ID], vTable3.Qty, vTable4.Currency, vTable5.Discount,
vTable5.Tax
ORDER BY vTable.[Customer ID], vTable.[SO ID]