472,352 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 software developers and data experts.

Case with greater than/less than

I'm trying to use a case to show increases/decreases. Not sure how to implement this is SQL. It should be something like this..
Select Case Change
Is >0 then 'Increase'
Is <0 then 'Decrease'
Else 'No Change'
From My_Table
Apr 19 '07 #1
8 37349
chandu031
78 Expert
Hi,

Your case statement should look something like this:

SELECT
CASE COUNT
WHEN > 0 THEN 'INCREASE'
WHEN < 0 THEN 'DECREASE'
ELSE 'NO CHANGE'
END AS COUNT
FROM MY_TABLE
Apr 20 '07 #2
I changed my query to..


Select Case Change
when >0 then 'Increase' /* <---the error points to this line */
when <0 then 'Decrease'
Else null
end as "Change"
From My_Table

and I get the following error message [1]: (Error): ORA-00936: missing expression
Apr 20 '07 #3
Saii
145 Expert 100+
try removing 'change' after case keyword
Apr 20 '07 #4
Change is the column i want to compare > or < 0. If it doenst go there, where does it go?
Apr 20 '07 #5
I would think that CHANGE might be reserved word somewhere in CASE SQL.

SELECT <myColumnSpec>
CASE
WHEN <A> THEN <somethingA>
WHEN <B> THEN <somethingB>
ELSE <somethingE>
END
Apr 20 '07 #6
I changed 'Change' to a differnt name and I get the same error. Here is the exact code I'm tryint to use..


SELECT
centers.cen_prt_code, centers.cen_center_num,
case centers.cen_center_num
when < 100 'Less then 100'
when > 200 'Greater than 200'
else 'Between 100 and 200'
end "Center is"
FROM XXXXXX.centers
WHERE ((centers.cen_prt_code = 'XXXXXXXX'))
Apr 20 '07 #7
Saii
145 Expert 100+
chk this.....

SELECT
centers.cen_prt_code, centers.cen_center_num,
case
when centers.cen_center_num< 100 'Less then 100'
when centers.cen_center_num > 200 'Greater than 200'
else 'Between 100 and 200'
end "Center is"
FROM XXXXXX.centers
WHERE ((centers.cen_prt_code = 'XXXXXXXX'))
Apr 20 '07 #8
Is this oracle? If so, do this:

SELECT
CASE WHEN
CHANGE > 0 THEN 'INCREASE'
WHEN < 0 THEN 'DECREASE'
ELSE 'NO CHANGE'
END AS COUNT
FROM MY_TABLE
Apr 20 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Hebar Tiltwobler | last post by:
I need to figure out if the current date (passed in as a string) is equal to or greater then a field in my database in the format of- M/D/YYYY AND...
5
by: Ryan | last post by:
I'm struggling with a Case statement. The problem I has is with doing >= I can use any value in there, but need to check if it's greater or equal...
10
by: clueless_google | last post by:
hello. i've been beating my head against a wall over this for too long. setting the variables 'z' or 'y' to differing numbers, the following...
10
by: MLH | last post by:
Suppose the following... Dim A as Date A=#7/24/2005# I wish to compare value of A against 2 other values: 1) 8/1/2005 2) 9/1/2005 Which...
7
by: BobRoyAce | last post by:
Let's say I have a text box on a page in which a user is to enter a monetary amount and that I want to ensure that the user enters a value greater...
3
by: Adam J. Schaff | last post by:
Hello. I recently noticed that the Sort method of the .NET ArrayList class does not behave as I expected. I expect 'A' < '_' < 'a' (as per their...
3
by: J-P-W | last post by:
"Stock Value" Could be anything from 0 to a million or so, and might include a decimal (12345.67) I can't find how to do this: Select Case...
2
by: AboutJAV | last post by:
Hi, In my code, I accept very long string, which may be greater than 2046 bytes. String can not exceed this limit. What else can I use to store...
8
by: John Ratliff | last post by:
Are case statement ranges standard C++ or a compiler extension? ex: switch (somevar) { case 0 ... 9: method1(); break; case 0xA: ... 0x23:...
6
by: Jim Richards | last post by:
I have a Combo1 with 254 items in it. I need to divide it into 2 case statements: Case 0 thru 246 and Case 247 thru 253 Mastering Visual...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.