Solved

case statement reserve word

Posted on 2006-11-09
9
293 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
9 Comments
 
LVL 13

Assisted Solution

by:rettiseert
rettiseert earned 100 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 100 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 

Author Comment

by:FrankPorter
ID: 17906855
cquinn,

It was for demonstration.
0
 
LVL 11

Accepted Solution

by:
Dany Balian earned 300 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

837 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