473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 38033
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 if the date is less then another field in my...
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 to 1. I'm sure I'm missing something but can't...
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 'if/else' code snippet works fine; however, the ...
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 is better and why... First:
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 than or equal to a certain value that will be...
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 ascii values) but what I got was the opposite....
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 StockValue Case 0 To 30000 response.Write("Less...
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 these very long string? Thanks,
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: method2(); break; } I thought they were...
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 Basic .Net, Page 139, very bottom of the page...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.