?
Solved

case statement reserve word

Posted on 2006-11-09
9
Medium Priority
?
296 Views
Last Modified: 2010-04-30
hi,

Please assist how can we use the case statement with the correct syntax, i've been having problems with reserve word?

    strRequest = "Select timevalue(datetime) as [DateTime], " & _
    " [case when 0=0 then 1 end] as [aaa] " & _
    " From [Mytable$]  " & _
    " group by timevalue(datetime);"

error returned "no value given for one or more required parameter."

Thanks.
0
Comment
Question by:FrankPorter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 13

Assisted Solution

by:rettiseert
rettiseert earned 400 total points
ID: 17906752
what db are your using?

in access you can use

Switch( var=val, 1, var2=val2, 2 ...)
0
 

Author Comment

by:FrankPorter
ID: 17906771
msexcel
0
 
LVL 15

Assisted Solution

by:cquinn
cquinn earned 400 total points
ID: 17906790
Why are you using a Case staement?  0=0 will always be true, so 1 would always be expected as the result, so just set it explicitly

   strRequest = "Select timevalue(datetime) as [DateTime], " & _
    " 1 as [aaa] " & _
    " From [Mytable$]  " & _
    " group by timevalue(datetime);"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:FrankPorter
ID: 17906855
cquinn,

It was for demonstration.
0
 
LVL 11

Accepted Solution

by:
Dany Balian earned 1200 total points
ID: 17907463
select case when field=value then 1 else 0 end as expr1, field, value from table group by field
0
 

Author Comment

by:FrankPorter
ID: 17907612
mrdany,

vb returned:
error returned "no value given for one or more required parameter."
0
 
LVL 11

Expert Comment

by:Dany Balian
ID: 17907798
well i need the field names... my fields were fictional... here's a good sql:

select case when parentcategory=category then 'main category' else 'sub category' end as categorytype,
category, parentcategory from categories group by category, parentcategory

can u give me ur sql, i can see what's wrong with it??

cheers
0
 

Author Comment

by:FrankPorter
ID: 17907813
this is the actual sql, i tried using the most basic. I'm using Ms Excel as database and VB as interface.

strRequest = "Select " & _
    " [case when 0=0 then 1 end] as [aaa] " & _
    " From [Mytable$] ; " 
.Open strRequest
0
 
LVL 11

Expert Comment

by:Dany Balian
ID: 17908363
i didnt get it.. does it work or not??

i tried it here, it's not working... i'm looking nito it..

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month8 days, 4 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question