| Chat with a LIVE Microsoft
Access Expert! |
||||
|
||||
|
#1
|
|||
|
|||
|
Query calculations
Thanks mainly to John K I have the following code from a previous post which identifies when a 'Unit' has been entered at 2 different 'JettyNumber' on the same 'StartDate'
Code:
SELECT Qry_All_Ops.StartDate, Qry_All_Ops.Unit, Count(Qry_All_Ops.Unit) AS CountOfUnit, Sum(Qry_All_Ops.JettyNumber) AS SumOfJettyNumber, [SumOfJettyNumber]/[CountOfUnit] AS Result, [result]=CInt([result]) AS Expr1 FROM Qry_All_Ops WHERE (((Qry_All_Ops.Operation)<>"Boat Transfer" And (Qry_All_Ops.Operation)<>"Diving")) GROUP BY Qry_All_Ops.StartDate, Qry_All_Ops.Unit, Qry_All_Ops.Status HAVING (((Count(Qry_All_Ops.Unit))>1) AND ((Qry_All_Ops.Status)="approved") AND ((Sum([Qry_All_Ops].[JettyNumber])/Count([Qry_All_Ops].[Unit])=CInt(Sum([Qry_All_Ops].[JettyNumber])/Count([Qry_All_Ops].[Unit])))=0)); Code:
[SumOfJettyNumber]/[CountOfUnit] I think I need to use CountOfUnit x JettyNumber <> SumOfJetty. If that equation is TRUE then there is a conflict, if FALSE then there isn't. I think I can get this to work if I can get [JettyNumber] into the same query that I already have [CountOfUnit] & [SumOfJetty]. Any clues please ? |
| Sponsored Links |
|
#2
|
|||
|
|||
|
I have finally managed to get this to work but have to have one query based on another. Can anyone help me to combine these two below into one please ?
First one named Qry_Test Code:
SELECT Qry_All_Ops.StartDate, Qry_All_Ops.Unit, First(Qry_All_Ops.JettyNumber) AS FirstOfJettyNumber, Last(Qry_All_Ops.JettyNumber) AS LastOfJettyNumber, Count(Qry_All_Ops.Unit) AS CountOfUnit, Sum(Qry_All_Ops.JettyNumber) AS SumOfJettyNumber FROM Qry_All_Ops WHERE (((Qry_All_Ops.Operation)<>"Diving" And (Qry_All_Ops.Operation)<>"Boat Transfer")) GROUP BY Qry_All_Ops.StartDate, Qry_All_Ops.Unit, Qry_All_Ops.Status HAVING (((Count(Qry_All_Ops.Unit))>1) AND ((Qry_All_Ops.Status)="approved")); Code:
SELECT Qry_Test.StartDate, Qry_Test.Unit, [Qry_Test]![CountOfUnit]*[Qry_Test]![FirstOfJettyNumber]<>[Qry_Test]![SumOfJettyNumber] AS Expr1 FROM Qry_Test WHERE ((([Qry_Test]![CountOfUnit]*[Qry_Test]![FirstOfJettyNumber]<>[Qry_Test]![SumOfJettyNumber])=-1)); |
| Sponsored Links |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Conditional Calculations in Query. | WhizzkidWallace | Queries | 2 | 01-26-2005 03:16 PM |
| Crosstable query returns too many records | Palsam | Queries | 2 | 03-09-2004 10:41 AM |
| Calculations in a Query | sedib | Queries | 1 | 09-09-2002 05:37 AM |
| Query to total calculations accross different queries. | Cosmos75 | Queries | 5 | 08-27-2002 06:42 AM |
| Multi-Table Query and Calculations | cinders | Queries | 2 | 08-28-2001 02:30 PM |