J
Jon Rowlan
I have query that returns all order lines for all orders, orders can have
between 1 and 10 order lines.
In then Group my query by Sales Rep.
and
count([ORDER NUMBER]), count([ORDER LINE])
both return the same number
As there are on average 2 lines per order then the count([ORDER NUMBER])
should return about half of count([ORDER LINE])
I have listed the SQL below ... I am wondering whether I am expecting too
much of this query and whether I should split it out into other queries ...
Can anyone advise please?
thanks,
jON
SELECT none_OEHEAD.ORDER_REP_CODE AS [Area Manager],
Count(none_OEHEAD.ORDER_NUMBER) AS [Number of Orders], Count([Order
Lines].ORDER_LINE) AS [Number of Lines],
Round(Sum(IIf([ORDER_TYPE]="C",-1,1)*[ORDER_VALUE]),2) AS [Order Value],
Round(Sum([Invoiced]*(IIf([ORDER_TYPE]="C",-1,1)*[ORDER_VALUE])),2) AS
[Invoice Value],
Round(Sum(IIf([ordered]-[allocated]-[delivered]-[invoiced]=0,0,(([ordered]-[allocated]-[delivered]-[invoiced])/[ordered])*(IIf([ORDER_TYPE]="C",-1,1)*[ORDER_VALUE]))),2)
AS [Backorder Value]
FROM [Order Lines], none_OEHEAD
WHERE (((none_OEHEAD.ORDER_NUMBER)=[Order Lines].[ORDER_NUMBER]) AND
((none_OEHEAD.ORDER_DATE)>=[Forms]![AM Sales Report]![FromDate] And
(none_OEHEAD.ORDER_DATE)<=[Forms]![AM Sales Report]![ToDate]) AND (([Order
Lines].ORDER_NUMBER)>=[Forms]![AM Sales Report]![StartingOrder]))
GROUP BY none_OEHEAD.ORDER_REP_CODE;
between 1 and 10 order lines.
In then Group my query by Sales Rep.
and
count([ORDER NUMBER]), count([ORDER LINE])
both return the same number
As there are on average 2 lines per order then the count([ORDER NUMBER])
should return about half of count([ORDER LINE])
I have listed the SQL below ... I am wondering whether I am expecting too
much of this query and whether I should split it out into other queries ...
Can anyone advise please?
thanks,
jON
SELECT none_OEHEAD.ORDER_REP_CODE AS [Area Manager],
Count(none_OEHEAD.ORDER_NUMBER) AS [Number of Orders], Count([Order
Lines].ORDER_LINE) AS [Number of Lines],
Round(Sum(IIf([ORDER_TYPE]="C",-1,1)*[ORDER_VALUE]),2) AS [Order Value],
Round(Sum([Invoiced]*(IIf([ORDER_TYPE]="C",-1,1)*[ORDER_VALUE])),2) AS
[Invoice Value],
Round(Sum(IIf([ordered]-[allocated]-[delivered]-[invoiced]=0,0,(([ordered]-[allocated]-[delivered]-[invoiced])/[ordered])*(IIf([ORDER_TYPE]="C",-1,1)*[ORDER_VALUE]))),2)
AS [Backorder Value]
FROM [Order Lines], none_OEHEAD
WHERE (((none_OEHEAD.ORDER_NUMBER)=[Order Lines].[ORDER_NUMBER]) AND
((none_OEHEAD.ORDER_DATE)>=[Forms]![AM Sales Report]![FromDate] And
(none_OEHEAD.ORDER_DATE)<=[Forms]![AM Sales Report]![ToDate]) AND (([Order
Lines].ORDER_NUMBER)>=[Forms]![AM Sales Report]![StartingOrder]))
GROUP BY none_OEHEAD.ORDER_REP_CODE;