Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

case statement reserve word

Posted on 2006-11-09
9
Medium Priority
?
297 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
Industry Leaders: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

604 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