473,503 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access SQL version of CASE?

What is the easiest way to write SQL that Access understands to achieve
simple standard SQL query below?

Thanks in Advance,

Phil
SELECT

charA,

CASE
WHEN charA < -199 THEN 2
WHEN charA < 31 THEN 3
WHEN charA < 82 THEN 4
WHEN charA < 100 THEN 5
WHEN charA < 105 THEN 6
WHEN charA < 111 THEN 7
WHEN charA < 143 THEN 8
WHEN charA < 165 THEN 9
WHEN charA < 233 THEN 10
WHEN charA >= 233 THEN 11
END AS Bin_charA

FROM X

Aug 22 '06 #1
2 22442
Bri


ph**********@hotmail.com wrote:
What is the easiest way to write SQL that Access understands to achieve
simple standard SQL query below?

Thanks in Advance,

Phil
SELECT

charA,

CASE
WHEN charA < -199 THEN 2
WHEN charA < 31 THEN 3
WHEN charA < 82 THEN 4
WHEN charA < 100 THEN 5
WHEN charA < 105 THEN 6
WHEN charA < 111 THEN 7
WHEN charA < 143 THEN 8
WHEN charA < 165 THEN 9
WHEN charA < 233 THEN 10
WHEN charA >= 233 THEN 11
END AS Bin_charA

FROM X
Take a look at the VBA Switch() function. Access allows you to use
functions in a query. So, some air code:

SELECT charA, Switch(charA < -199, 2, charA < 31, 3,charA >= 233, 11) AS
Bin_charA FROM X

Aug 22 '06 #2
ph**********@hotmail.com wrote:
What is the easiest way to write SQL that Access understands to achieve
simple standard SQL query below?

Thanks in Advance,

Phil
SELECT

charA,

CASE
WHEN charA < -199 THEN 2
WHEN charA < 31 THEN 3
WHEN charA < 82 THEN 4
WHEN charA < 100 THEN 5
WHEN charA < 105 THEN 6
WHEN charA < 111 THEN 7
WHEN charA < 143 THEN 8
WHEN charA < 165 THEN 9
WHEN charA < 233 THEN 10
WHEN charA >= 233 THEN 11
END AS Bin_charA

FROM X
As noted, Switch can be used. Switch is a function. If working with
A97, you'd use a function. Switch is a function, so if switch() isn't
available, you'd roll your own. Create a new column in the query. Ex:
Rank : GetRank([CharA])

Function GetRank(varC As Variant) As Integer
Select Case VarC
Case <-199
....
Case Else
GetRank = 0
End Select
End Function
Aug 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5394
by: RWC | last post by:
Hi Folks, I'm looking for a way to determine if the client machine has access installed and if so, what version. The reason I need this is to determine (programatically) if the Access Runtime...
14
5385
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
4
8053
by: Jenni | last post by:
Hi, A quick question. I have been battling with this code all morning, please help. Here is the code Dim fPath1 As String Dim fPath2 As String fPath1 = "C:\Program Files\Microsoft...
6
4712
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
1
24000
by: Me | last post by:
Hi all, I have an Access application that has to import hundreds of other MDB's, some access 97 and some 2000, and merge them into several large mdb's. so far so good, but my command: Set...
7
8821
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
6551
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
4
7132
by: Br | last post by:
We're using an Access2000 ADP with an SQL2000 back-end. Because SQL2000 was released after Access2000 you need to be running Access2000 SP1 (2 or 3) for it to work properly. Is there an easy way...
7
5339
by: bhavin30 | last post by:
Is there a way to obtain user information (using LOGON_USER server variables) when you have set up the security to Anonymous Access? I have tried setting the security to both Anonymous + Window...
17
7646
by: Neil | last post by:
A client of mine likes some of the new bells and whistles in Access 2007, and is thinking about converting our A03 format MDB to an A07 format file. However, while some of the users have A07, many...
0
7201
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
7278
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,...
1
6988
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
5578
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
5011
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
4672
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...
0
3153
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
734
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.