satinsilhouette
Instructor
- Feb 21, 2006
- 625
I found something on a SQL board about using a case statement in the where clause and haven't gotten it to work yet.
Need: a data field that can have one choice, a range of choices or no choices.
Control group is the field and it looks like:
Control Group Start ______ Control Group End ______
The case statement I put together says has missing key word:
SELECT CONTROL_GROUP, JE_TYPE
FROM GLTRANS
WHERE (CASE CONTROL_GROUP WHEN :STARTJENO IS NULL AND :ENDJENO IS NULL THEN 1 ELSE 0 WHEN :STARTJENO IS NOT NULL AND
:ENDJENO IS NULL THEN 1 ELSE 0 WHEN BETWEEN :STARTJENO AND :ENDJENO THEN 1 ELSE 0 END = 1)
Any ideas what I am doing wrong here? This is my first attempt at using a case statement in the where clause.
Thanks so much!
satinsilhouette
Need: a data field that can have one choice, a range of choices or no choices.
Control group is the field and it looks like:
Control Group Start ______ Control Group End ______
The case statement I put together says has missing key word:
SELECT CONTROL_GROUP, JE_TYPE
FROM GLTRANS
WHERE (CASE CONTROL_GROUP WHEN :STARTJENO IS NULL AND :ENDJENO IS NULL THEN 1 ELSE 0 WHEN :STARTJENO IS NOT NULL AND
:ENDJENO IS NULL THEN 1 ELSE 0 WHEN BETWEEN :STARTJENO AND :ENDJENO THEN 1 ELSE 0 END = 1)
Any ideas what I am doing wrong here? This is my first attempt at using a case statement in the where clause.
Thanks so much!
satinsilhouette