Hi,
I'm not an Access expert and understand with MS SQL Server 7 or 2000,
a query like this would work
Select osName, count(*) as osCount From osTable
Where osName is not Null
Group By
Case When Left(osName,7)='Windows' Then 'Windows OS' Else 'Other
OS' End
would work, however, it won't in Access, what could Access's equivalent
be to get the same result set?
TIA. 9 4282
try something like this:
SELECT IIf(Left(os,3)='win','windos os','other os') AS Expr1, Count(*)
AS Expr2
FROM osTable
GROUP BY IIf(Left(os,3)='win','windos os','other os');
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Interesting. IIF fuction never registers with me. However, I have
more than 2 scenarios to take care of,
How If ... Else if ... Else if ... Else
to replace IIF?
Does not seem to work.
Thanks.
Rich P wrote: try something like this:
SELECT IIf(Left(os,3)='win','windos os','other os') AS Expr1, Count(*) AS Expr2 FROM osTable GROUP BY IIf(Left(os,3)='win','windos os','other os'); Rich
*** Sent via Developersdex http://www.developersdex.com ***
For multiple cases, use Switch:
Select Switch(Left(os,3)="win", "Windows OS", Left(os, 3) ="mac","MAC OS",
test3, value3, test4, value4..., true, "Value '" & os & "' does not match
any test")
If you don't cover absolutely every possibility in the listed tests, always
include a test for true as the last test and some message that alerts you
according to the severity of the fact that none of your pre-defined tests
passed. Sometimes it doesn't matter.
You can have nested IIF statements. If the IIF statement doesn't work
for you then you must be using either an older version of Access or
Access needs to be reinstalled. My example is using IIF on Access2000.
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Got "invalid procedure call" error from a normal query statement.
btw, the query looks like this:
SELECT Switch(Left(os.osName,7)='Windows', "Windows OS",
Left(os.osName,4)='Unix', "Unix OS",
Left(os.osname,8)="Other OS",
true, "Others") as OS
FROM osTable
Look like the Switch is available for Module or the like but not for
normal query.
Thanks.
Rick Wannall wrote: For multiple cases, use Switch:
Select Switch(Left(os,3)="win", "Windows OS", Left(os, 3) ="mac","MAC OS", test3, value3, test4, value4..., true, "Value '" & os & "' does not match any test")
If you don't cover absolutely every possibility in the listed tests, always include a test for true as the last test and some message that alerts you according to the severity of the fact that none of your pre-defined tests passed. Sometimes it doesn't matter.
My typo, yes it works and good to know. Many thanks.
NickName wrote: Got "invalid procedure call" error from a normal query statement.
btw, the query looks like this: SELECT Switch(Left(os.osName,7)='Windows', "Windows OS", Left(os.osName,4)='Unix', "Unix OS", Left(os.osname,8)="Other OS", true, "Others") as OS FROM osTable
Look like the Switch is available for Module or the like but not for normal query.
Thanks.
Rick Wannall wrote: For multiple cases, use Switch:
Select Switch(Left(os,3)="win", "Windows OS", Left(os, 3) ="mac","MAC OS", test3, value3, test4, value4..., true, "Value '" & os & "' does not match any test")
If you don't cover absolutely every possibility in the listed tests, always include a test for true as the last test and some message that alerts you according to the severity of the fact that none of your pre-defined tests passed. Sometimes it doesn't matter.
Switch works fine in queries. In any module, select Tools | References and
make sure you have Visual Basic for Applications selected.
Yes, "Switch works fine in queries", you're right, many thanks.
Rick Wannall wrote: Switch works fine in queries. In any module, select Tools | References and make sure you have Visual Basic for Applications selected.
"Rick Wannall" <wa*****@notadomain.de> wrote in
news:BB*******************@newssvr21.news.prodigy. com: Switch works fine in queries. In any module, select Tools | References and make sure you have Visual Basic for Applications selected.
Any built-in Access function should work in queries (user-defined
ones, too). That's the whole point of the magic of the Access
Expression Service that makes Access such a powerful tool.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hareesh |
last post by:
Hi,
-- SQL Stmt 1
SELECT * FROM Table1
WHERE Field1 = 123
AND Field2 = 234
AND Field3 = 345
AND Field4 = 456
AND Field5 = 567
AND Field6 = 678
|
by: claus.hirth |
last post by:
I wrote a stored procedure that uses a prepared INSERT INTO statement
in order to play with the PREPARE and EXECUTE keywords.
In transcript 1 below the call to that stored procedure does not...
|
by: Uzytkownik |
last post by:
I've some function:
function show($id) {
$title = $text = $date = $nick = NULL;
$stmt = $this->base->stmt_init();
$stmt->prepare("SELECT title,text,datetime,nick FROM posts LEFT JOIN authors ON...
|
by: subin78 |
last post by:
Hi All,
Im new to DB2. I need to to write a query using CASE stmt
the Scenario is like this
when
DAYNAME = 'sunday' select * from table where LASTUPDATE = current date-1
else select...
|
by: Kingsly |
last post by:
How to read "stmt" column of "sysibm.syspackstmt" table in a readable format?
select stmt from sysibm.syspackstmt where name like 'MYPROC1';
I was expecting the stored procedure statements as...
|
by: siddu |
last post by:
select country,
IsNull(A,0) as A,
IsNull(B,0) as B,
---- Here I need to add case stmt. I have data B in Db if it is B then I have to show C else I have to C
from <Table-name>
Please...
|
by: Adem |
last post by:
C/C++ language proposal:
Change the 'case expression' from "integral constant-expression" to "integral expression"
The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15)
says under...
|
by: pankaj17 |
last post by:
hello everyone,
MYSQL query ............
how to set prepare stmt result in variable
i have written prepare stmt in store procedure and i want to set result of prepare stmt in variable
...
|
by: pankaj17 |
last post by:
hello everyone,
MYSQL query ............
how to set prepare stmt result in variable
i have written prepare stmt in store procedure and i want to set result of prepare stmt in variable
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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,...
| |