If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Use first record found in expression?
My calculation is coming up with two different values for the following SQL:
SELECT A.ID, A.Site, A.[Date Monitored], A.[Opt Time Final], A.[TSFR VAL], ((C.[Est VFH Conc1]-B.[Est VFH Conc1]) /(C.[Opt Time Final]-B.[Opt Time Final])) When it "looks ahead" for which C.[Opt Time Final] value to use, its calculating two different results because when it looks at: AND C.[Opt Time Final]=(Select MIN(Y.[Opt Time Final]) FROM [System tbl 0064 VFH qry] AS Y WHERE A.[Opt Time Final] Y.[Opt Time Final] AND Y.[Est VFH Conc1] 0) It finds two (or more) records that fit this expression. How can I tell it to look at just the first one ahead of it & no others? I do have a date field in the table that's unique. I tried adding this to the SQL but it didn't seem to produce the right results: AND B.[Date Monitored]=(SELECT MAX(X.[Date Monitored]) FROM [System tbl 0064 VFH qry] AS X WHERE X.[Date Monitored] A.[Date Monitored]) *(A.[Opt Time Final]-B.[Opt Time Final]) +(B.[Est VFH Conc1]) AS Calc1 FROM [System tbl 0064 VFH qry] AS A, [System tbl 0064 VFH qry] AS B, [System tbl 0064 VFH qry] AS C WHERE A.[Opt Time Final]=[b].[Opt Time Final] AND A.[Opt Time Final]=[C].[Opt Time Final] AND A.[Est VFH Conc1] = 0 AND B.[Est VFH Conc1] 0 AND C.[Est VFH Conc1] 0 AND B.[Opt Time Final]=(SELECT MAX(X.[Opt Time Final]) FROM [System tbl 0064 VFH qry] AS X WHERE X.[Opt Time Final]= A.[Opt Time Final] AND X.[Est VFH Conc1]0) AND C.[Opt Time Final]=(Select MIN(Y.[Opt Time Final]) FROM [System tbl 0064 VFH qry] AS Y WHERE A.[Opt Time Final] Y.[Opt Time Final] AND Y.[Est VFH Conc1] 0) UNION SELECT Z.[ID], Z.[Site], Z.[Date Monitored], Z.[Opt Time Final], Z.[TSFR Val], 0 As Calc1 FROM [system tbl 0064 VFH qry] AS Z WHERE Z.[Est VFH Conc1] 0; |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Change and Save a Record | sara | Using Forms | 0 | July 17th, 2004 04:47 PM |
Button to print current record only | Fatz | Using Forms | 6 | June 17th, 2004 01:58 PM |
Form Doesn't Go To New Record | Steve | New Users | 15 | May 16th, 2004 04:33 PM |
Form Does Not Go To New Record | Steve | New Users | 1 | May 12th, 2004 03:15 AM |
Avoid Creating A Duplicate Record | Mark | New Users | 4 | May 11th, 2004 01:52 AM |