473,394 Members | 1,382 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,394 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 38085
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.