Query Format Help

  • Thread starter LDA via AccessMonster.com
  • Start date
L

LDA via AccessMonster.com

Hello,

I have four main fields. order id, sample number, Test, Param
I am trying to count the number of parameters for each Test within a query.
Once the number of parameters for each test has been counted I would like to
use that number in an equation. If the test is a single price test, as
indicated from a table, then final charge is equated to being: Price
Mulitipler* Price. If not final charge is equated as being; Count of params *
Price
Mulitipler.


For example

OrderID SampleNumber, Test, Param (Random field[results]
)

j09 2001 abc joy 74ml
j09 2001 abc hope .33ml
j09 2001 abc faith 22ml
j09 2001 xyz bug 11ml


Below is example of the current SQL.

SELECT DISTINCT Results.OrderID, SampleDetails.Matrix, Customers.CustomerName,
Results.Test, Results.Param, SampleDetails.Priority, Results.SampleNumber,
SampleDetails.AnalysisEmployee, Tests.Cost, Priorities.PriceMultiplier,
Duke_OrderInfo.SampleType, Duke_OrderInfo.StatCode, Results.Method,
TestPrices.Price, Results.Report, duke_accounting_testcharge1.singleprice,
Results.orderid, Count(Results.param) AS CountOfparam, Results.EnteredDate
FROM (Duke_Accounting_TestCharge INNER JOIN ((((((Results INNER JOIN Orders
ON Results.OrderID = Orders.OrderID) INNER JOIN Customers ON Orders.
CustomerID = Customers.CustomerID) INNER JOIN SampleDetails ON (Results.Test
= SampleDetails.Test) AND (Results.SampleNumber = SampleDetails.SampleNumber)
AND (Results.OrderID = SampleDetails.OrderID)) INNER JOIN (Tests INNER JOIN
TestPrices ON (Tests.Test = TestPrices.Test) AND (Tests.Method = TestPrices.
Method)) ON (SampleDetails.Matrix = Tests.Matrix) AND (SampleDetails.Test =
Tests.Test)) INNER JOIN Priorities ON SampleDetails.Priority = Priorities.
Priority) INNER JOIN Duke_OrderInfo ON Results.OrderID = Duke_OrderInfo.
OrderID) ON Duke_Accounting_TestCharge.Test = Tests.Test) INNER JOIN
duke_accounting_testcharge1 ON (Duke_Accounting_TestCharge.Test =
duke_accounting_testcharge1.Test) AND (Priorities.Priority =
duke_accounting_testcharge1.Priority)
GROUP BY Results.OrderID, SampleDetails.Matrix, Customers.CustomerName,
Results.Test, Results.Param, SampleDetails.Priority, Results.SampleNumber,
SampleDetails.AnalysisEmployee, Tests.Cost, Priorities.PriceMultiplier,
Duke_OrderInfo.SampleType, Duke_OrderInfo.StatCode, Results.Method,
TestPrices.Price, Results.Report, duke_accounting_testcharge1.singleprice,
Results.orderid, Results.EnteredDate
ORDER BY Results.SampleNumber;


Any suggestions are welcomed.

Thanks

LDA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Query Speed/Indexes 6
query/transform/crosstab?? 0
cross tab query help 3

Top