473,508 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lookup Function in SQL

1 New Member
Hi, I have an access database where I have the following function to lookup values:

Expand|Select|Wrap|Line Numbers
  1. Public Function PEARlookup(findApple As Double) As Double
  2. Dim qdf As QueryDef
  3. Dim rst As Recordset
  4.  
  5. Set qdf = CurrentDb.CreateQueryDef("", "SELECT T1.ORANGE FROM PEARtable AS T1 WHERE T1.Seeds=(SELECT Max(T2.Seeds) FROM PEARtable AS T2 WHERE T2.Seeds<=[Value];);")
  6. qdf.Parameters("Value") = CDbl(findApple)
  7. Set rst = qdf.OpenRecordset
  8. If rst.RecordCount > 0 Then PEARlookup = rst!ORANGE
  9. rst.Close
  10. qdf.Close
  11.  
  12. End Function

Now I do the same thing in SQL but I use a query that has (non equi) joins of <= and >. The function above runs much more efficiently (hours more so) but I can't create a function in SQL using a Select statement. Anyone have any ideas how to easily look up non equal values in SQL?
Dec 10 '07 #1
0 2826

Sign in to post your reply or Sign up for a free account.

Similar topics

11
18993
by: John Collyer | last post by:
Hi, In assembly language you can use a lookup table to call functions. 1. Lookup function address in table 2. Call the function Like: CALL FUNCTION
1
1978
by: Srini | last post by:
I was reading the "Exceptional C++" of Herb Sutter. In an example, he mentions the following. // In some library header: namespace N { class C{}; } int operator+(int i, N::C) { return i+1; }...
8
2015
by: Lucas Lemmens | last post by:
Dear pythonians, I've been reading/thinking about the famous function call speedup trick where you use a function in the local context to represent a "remoter" function to speed up the 'function...
10
3788
by: junky_fellow | last post by:
what are lookup tables ? How can they be used to optimise the code ?
3
1227
by: Andy G | last post by:
I have a page that is used for the user to edit their information on file. I need to lookup all of their info using their ID. Do I use a lookup function on each text box/drop down list or should I...
7
2700
by: Juris Krumins | last post by:
I have a problem with postgresql tables. periodicaly, I would say frequently about 5-10 time per hour i have such errors in my server log file: 2004-04-14 12:23:32 ERROR: cache lookup of...
4
1528
by: Dilip | last post by:
How did the Koenig lookup come to be associated with templates? If I have something like this: (no template code) namespace X { enum E { e1 }; void f(E) { } }
4
1473
by: Andrea Griffini | last post by:
Hello, I implemented that crazy idea and seems working... in its current hacked state can still pass the test suite (exluding the tests that don't like self generated output on stdout from...
13
5572
by: paul.joseph.davis | last post by:
Hi, I've just had my first encounter with two-phase lookup and I'm scratching my head a bit. The idea behind two phase look up is pretty easy to understand, but I have a case that fails to...
1
2273
by: joeino | last post by:
I want to do a lookup query and append the record to a history table before editing the data. I created a macro to run the lookup query to append the record to history and it works fine. I did the...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.