If I sort all the records as "Ascending" and look at the SQL view of
this query, I get the following:
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, ([DS47]*[PLT47])/[ADC47] AS TInv47,
([DS43]*[PLT43])/[ADC43] AS TInv43, ([DS5]*[PLT5])/[ADC5] AS TInv5,
([DS4]*[PLT4])/[ADC4] AS TInv4, ([DS6]*[PLT6])/[ADC6] AS TInv6,
([DS37]*[PLT37])/[ADC37] AS TInv37, ([DS38]*[PLT38])/[ADC38] AS
TInv38, ([DS39]*[PLT39])/[ADC39] AS TInv39, ([DS40]*[PLT40])/[ADC40]
AS TInv40, ([DS57]*[PLT57])/[ADC57] AS TInv57, ([DS59]*[PLT59])/
[ADC59] AS TInv59, ([DS64]*[PLT64])/[ADC64] AS TInv64,
([DS41]*[PLT41])/[ADC41] AS TInv41
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
ORDER BY ([DS47]*[PLT47])/[ADC47], ([DS43]*[PLT43])/[ADC43],
([DS5]*[PLT5])/[ADC5], ([DS4]*[PLT4])/[ADC4], ([DS6]*[PLT6])/[ADC6],
([DS37]*[PLT37])/[ADC37], ([DS38]*[PLT38])/[ADC38], ([DS39]*[PLT39])/
[ADC39], ([DS40]*[PLT40])/[ADC40], ([DS57]*[PLT57])/[ADC57],
([DS59]*[PLT59])/[ADC59], ([DS64]*[PLT64])/[ADC64], ([DS41]*[PLT41])/
[ADC41];
Which is what I think Michael suggested, but unfortunately not what I
wanted. I need to be able to sort the fields (i.e. the indivdual
query results one row of data) in order. So for example, the
calculated result of (DieSet47 * Pallet47)/ ShiftUsage47 =
TotalInventory47 and (DieSet43*Pallet43)/ShiftUsage43 =
TotalInventory43 and so on..... I need to sort:
TInv47, TInv43, TInv5, TInv6......and so on from the lowest value to
the highest. Similar to the "=SMALL" function in
Excel where the results of the calculated field i.e. 0.13; 1.1; 2.7;
0.01; 2.3 are sorted as 0.01; 0.13; 1.1; 2.3; 2.7
Does this explain it better?
I'm thinking something like:
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift,
'TInv4' AS calc_name,
([DS4]*[PLT4])/[ADC4] AS calc_result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift,
'TInv5' AS calc_name,
([DS5]*[PLT5])/[ADC5] AS cal_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift,
'TInv6' AS calc_name,
([DS6]*[PLT6])/[ADC6] AS calc_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
...
etc
...
ORDER BY 1, 2, 3, 5;
Does this get you any further?
Jamie.
--- Hide quoted text -
- Show quoted text -
Hi Jamie,
So, if I understand you correctly, my SQL statement should read as
follows:
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv47'AS calc_name,([DS47]*[PLT47])/
[ADC47] AS calc_result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv43' AS calc_name, ([DS43]*[PLT43])/
[ADC43] AS calc_result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv5' AS calc_name,([DS5]*[PLT5])/
[ADC5] AS calc_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv4' AS calc_name, ([DS4]*[PLT4])/
[ADC4] AS calc_result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv6' AS calc_name, ([DS6]*[PLT6])/
[ADC6] AS calc_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv37' AS calc_name, ([DS37]*[PLT37])/
[ADC37] AS calc_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv38' AS calc_name, ([DS38]*[PLT38])/
[ADC38] AS calc_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv39' AS calc_name, ([DS39]*[PLT39])/
[ADC39] AS calc_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv40' AS calc_name, ([DS40]*[PLT40])/
[ADC40] AS calc_result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv57' AS calc_name,([DS57]*[PLT57])/
[ADC57] AS calc_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv59' AS calc_name,([DS59]*[PLT59])/
[ADC59] AS calc_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv64' AS calc_name, ([DS64]*[PLT64])/
[ADC64] AS calc_ result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
SELECT [1AInventoryTable].txtDate, [1AInventoryTable].txtTime,
[1AInventoryTable].txtShift, 'TInv41' AS calc_name, ([DS41]*[PLT41])/
[ADC41] AS calc_result
FROM 1AInventoryTable, 1APalletTable, 1AShiftUsage
UNION ALL
ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
Maybe I need another pair of eyes to check this because I get an error
statement that reads:
"The SELECT statement contains a reserved word or an argument name
that is misspelled or missing, or the
punctuation is incorrect."