By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

doubt in CASE command

priyan
P: 54
Hi all,
I am having a table and there is a column named id. I have to choose the id and in case if id is null i have set id to '1' otherwise the same id should be displayed. For this i tried the following query but the result is not the proper one which i expect pls help me in this regard
Expand|Select|Wrap|Line Numbers
  1. select substring(number,2), case when substring(number,2) is null then '1' else substring(number,2) end as id  from emp
  2.  
Expand|Select|Wrap|Line Numbers
  1.                                                  substring  id
  2.  
  3.  
  4.  
  5.  
  6.  224       224
  7.  
Nov 16 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 700
Hi all,
I am having a table and there is a column named id. I have to choose the id and in case if id is null i have set id to '1' otherwise the same id should be displayed. For this i tried the following query but the result is not the proper one which i expect pls help me in this regard
Expand|Select|Wrap|Line Numbers
  1. select substring(number,2), case when substring(number,2) is null then '1' else substring(number,2) end as id  from emp
  2.  
Expand|Select|Wrap|Line Numbers
  1.                                                  substring  id
  2.  
  3.  
  4.  
  5.  
  6.  224       224
  7.  
What does your table look like. Show data.
Nov 16 '07 #2

Post your reply

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