D
DawnTreader
Hello All
here is the SQL i am working on:
SELECT
dbo_CUSTOMER.NAME AS CustomerName,
dbo_CUSTOMER_ORDER.CUSTOMER_ID AS CustomerID,
dbo_CUSTOMER_ORDER.ID AS OrderID,
dbo_CUST_ORDER_LINE.PART_ID AS IMWPartID,
dbo_PART.DESCRIPTION AS Description,
dbo_CUST_ORDER_LINE.ORDER_QTY AS Qty,
nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0)
AS VisualCostPrice,
nz([dbo_PART].[UNIT_PRICE],0) AS VisualListPrice,
(nz([dbo_PART].[UNIT_PRICE],0)*0.9) AS VLPLess10Percent,
([VisualListPrice]-[VisualCostPrice])/[VisualListPrice] AS Margin,
((nz([dbo_PART].[UNIT_PRICE],0)*0.9)-(nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0)))/(nz([dbo_PART].[UNIT_PRICE],1)*0.9)
AS VCPmVLPL10P
FROM (dbo_CUSTOMER_ORDER LEFT JOIN (dbo_CUST_ORDER_LINE LEFT JOIN dbo_PART
ON dbo_CUST_ORDER_LINE.PART_ID = dbo_PART.ID) ON dbo_CUSTOMER_ORDER.ID =
dbo_CUST_ORDER_LINE.CUST_ORDER_ID) LEFT JOIN dbo_CUSTOMER ON
dbo_CUSTOMER_ORDER.CUSTOMER_ID = dbo_CUSTOMER.ID
GROUP BY dbo_CUSTOMER.NAME, dbo_CUSTOMER_ORDER.CUSTOMER_ID,
dbo_CUSTOMER_ORDER.ID, dbo_CUST_ORDER_LINE.PART_ID, dbo_PART.DESCRIPTION,
dbo_CUST_ORDER_LINE.ORDER_QTY,
nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0),
nz([dbo_PART].[UNIT_PRICE],0), (nz([dbo_PART].[UNIT_PRICE],0)*0.9),
([VisualListPrice]-[VisualCostPrice])/[VisualListPrice],
((nz([dbo_PART].[UNIT_PRICE],0)*0.9)-(nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0)))/(nz([dbo_PART].[UNIT_PRICE],1)*0.9)
HAVING (((dbo_CUSTOMER.NAME) Like "imw*shang*") AND
((dbo_CUST_ORDER_LINE.PART_ID) Is Not Null) AND
((dbo_CUST_ORDER_LINE.ORDER_QTY)>0))
ORDER BY ([VisualListPrice]-[VisualCostPrice])/[VisualListPrice] DESC;
i know the spaces are unnecessary, but i thought it would help in readability.
the problem is:
((nz([dbo_PART].[UNIT_PRICE],0)*0.9)-(nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0)))/(nz([dbo_PART].[UNIT_PRICE],1)*0.9)
AS VCPmVLPL10P
this is the same as the margin calculation. the problem is that if i use the
margin calculation i get 2 parameter dialogs, the problem with the
VCPmVLPL10P is that at one point i got a division by zero error and now i am
getting an expression to complex.
i dont understand why i get either. the formula actually worked a few
minutes before.
i am thinking that it may have something to do with the fact that the data
comes from a live database that is being constantly used. but i need to be
sure that the SQL is correct, hence my post.
any and all help appreciated.
here is the SQL i am working on:
SELECT
dbo_CUSTOMER.NAME AS CustomerName,
dbo_CUSTOMER_ORDER.CUSTOMER_ID AS CustomerID,
dbo_CUSTOMER_ORDER.ID AS OrderID,
dbo_CUST_ORDER_LINE.PART_ID AS IMWPartID,
dbo_PART.DESCRIPTION AS Description,
dbo_CUST_ORDER_LINE.ORDER_QTY AS Qty,
nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0)
AS VisualCostPrice,
nz([dbo_PART].[UNIT_PRICE],0) AS VisualListPrice,
(nz([dbo_PART].[UNIT_PRICE],0)*0.9) AS VLPLess10Percent,
([VisualListPrice]-[VisualCostPrice])/[VisualListPrice] AS Margin,
((nz([dbo_PART].[UNIT_PRICE],0)*0.9)-(nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0)))/(nz([dbo_PART].[UNIT_PRICE],1)*0.9)
AS VCPmVLPL10P
FROM (dbo_CUSTOMER_ORDER LEFT JOIN (dbo_CUST_ORDER_LINE LEFT JOIN dbo_PART
ON dbo_CUST_ORDER_LINE.PART_ID = dbo_PART.ID) ON dbo_CUSTOMER_ORDER.ID =
dbo_CUST_ORDER_LINE.CUST_ORDER_ID) LEFT JOIN dbo_CUSTOMER ON
dbo_CUSTOMER_ORDER.CUSTOMER_ID = dbo_CUSTOMER.ID
GROUP BY dbo_CUSTOMER.NAME, dbo_CUSTOMER_ORDER.CUSTOMER_ID,
dbo_CUSTOMER_ORDER.ID, dbo_CUST_ORDER_LINE.PART_ID, dbo_PART.DESCRIPTION,
dbo_CUST_ORDER_LINE.ORDER_QTY,
nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0),
nz([dbo_PART].[UNIT_PRICE],0), (nz([dbo_PART].[UNIT_PRICE],0)*0.9),
([VisualListPrice]-[VisualCostPrice])/[VisualListPrice],
((nz([dbo_PART].[UNIT_PRICE],0)*0.9)-(nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0)))/(nz([dbo_PART].[UNIT_PRICE],1)*0.9)
HAVING (((dbo_CUSTOMER.NAME) Like "imw*shang*") AND
((dbo_CUST_ORDER_LINE.PART_ID) Is Not Null) AND
((dbo_CUST_ORDER_LINE.ORDER_QTY)>0))
ORDER BY ([VisualListPrice]-[VisualCostPrice])/[VisualListPrice] DESC;
i know the spaces are unnecessary, but i thought it would help in readability.
the problem is:
((nz([dbo_PART].[UNIT_PRICE],0)*0.9)-(nz([dbo_PART]![UNIT_MATERIAL_COST],0)+nz([dbo_PART]![UNIT_LABOR_COST],0)+nz([dbo_PART]![UNIT_BURDEN_COST],0)+nz([dbo_PART]![UNIT_SERVICE_COST],0)))/(nz([dbo_PART].[UNIT_PRICE],1)*0.9)
AS VCPmVLPL10P
this is the same as the margin calculation. the problem is that if i use the
margin calculation i get 2 parameter dialogs, the problem with the
VCPmVLPL10P is that at one point i got a division by zero error and now i am
getting an expression to complex.
i dont understand why i get either. the formula actually worked a few
minutes before.
i am thinking that it may have something to do with the fact that the data
comes from a live database that is being constantly used. but i need to be
sure that the SQL is correct, hence my post.
any and all help appreciated.