473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

COUNT(CASE WHEN...

Hello,

Do Access queries support the CASE WHEN SQL command? Whenever I try to
use them, I get a syntax error (missing operator) and the word WHEN is
highlighted.

For Example:

SELECT
COUNT(CASE WHEN MyField <20 THEN 1 ELSE NULL END)
FROM MyTable;

FYI, the WHEN and MyField can be reversed and still be correct SQL
Syntax:

SELECT
COUNT(CASE MyField WHEN <20 THEN 1 ELSE NULL END)
FROM MyTable;
Both methods work fine in SQL Query Analyzer but not in Access.
Thanks in advance for your comments.

Jeremy
Nov 13 '05 #1
1 14457
"Mr. Bungle" <sl********@hotmail.com> wrote in message
news:ab*************************@posting.google.co m...
Hello,

Do Access queries support the CASE WHEN SQL command? Whenever I try to
use them, I get a syntax error (missing operator) and the word WHEN is
highlighted.

For Example:

SELECT
COUNT(CASE WHEN MyField <20 THEN 1 ELSE NULL END)
FROM MyTable;

FYI, the WHEN and MyField can be reversed and still be correct SQL
Syntax:

SELECT
COUNT(CASE MyField WHEN <20 THEN 1 ELSE NULL END)
FROM MyTable;
Both methods work fine in SQL Query Analyzer but not in Access.
Thanks in advance for your comments.


CASE is not supported in Access/Jet. Check the help files for functions IIf() ,
Switch(), Choose(). They can usually provide similar functionality

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2

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

Similar topics

2
by: Robert | last post by:
Just a quick question, how do I divide the results of these two queries together ? (select count (*) as ontime from schedule where actualarrivaldate <= estimatearrivaldate) (select count (*)...
0
by: Dave Hammond | last post by:
When using mysqlimport, the final statistics include a count of "Warnings", for example: Connecting to foo.whatever.com Selecting database foo Loading data from LOCAL file: foo_userInfo.imp...
5
by: DaaaDaaa | last post by:
Hi, Here's what I'd like to do: table (Orders) has fields of Processed, Paid (both of boolean yes|no) etc, I want to return a count of of Total number of Orders, Number of Processed vs. Number...
2
by: Donald Smith | last post by:
Hey, does anyone know how to put this into a switch() statement? switch(lvLogs.Items.Count) { case < 1: Bitmap myBitmap_Error = new Bitmap(imageList1.Images); Icon myIcon_Error =...
9
by: Eric S. | last post by:
Why doesn't something like this work? I get "a constant value is expected" on all 3 case statements. private DataGrid CurrentDataGrid(DataGrid firstDg, DataGrid secondDg) { try { switch...
2
by: kumar mcmillan | last post by:
hi. I am using a pseudo "pivot table" SQL query to generate a report but I am totally stumped on why the COUNT() function isn't getting me the expected results and was wondering if anyone has some...
4
by: Danielle | last post by:
I have data like this in a two column temporary table - ID Age 23586 3 23586 3 23586 2 23586 2 23586 1 23586 1
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
1
by: k4 | last post by:
I have a database that contains a column for UnitName , BeginDate and EndDate. I want to pass two parameters (@BeginDate and @EndDate) and retrieve a table of values that include UnitName...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...

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.