| Author |
Topic |
|
toprasad
Starting Member
4 Posts |
Posted - 2008-05-08 : 07:26:10
|
| Hi,I have a table called emp, having 2 field name & sexvalues are:name sexa 1b 2c 1now i want to display the values in above table as like below...name sexa Maleb Femalec MaleHow to do that...? |
|
|
Vadivu
Starting Member
31 Posts |
Posted - 2008-05-08 : 07:30:01
|
| update emp set sex = case when sex =1 then 'Male' else ' Female' endhope the column is not of type intThought u wanted to update the table.. In case u just want to display the data, thenselect sex = case when sex =1 then 'Male' else 'Female' end from emp |
 |
|
|
toprasad
Starting Member
4 Posts |
Posted - 2008-05-08 : 07:54:10
|
| Hi, Thanks for reply.I dont want to update the table as u expected.I just want to display the result using select statement.I executed the ur mentioned statement but i got the following error."ORA-00923: FROM keyword not found where expected"It seems to be syntax problem....????? |
 |
|
|
Vadivu
Starting Member
31 Posts |
Posted - 2008-05-08 : 07:58:03
|
| this query works perfectly fine in sql server |
 |
|
|
toprasad
Starting Member
4 Posts |
Posted - 2008-05-08 : 08:04:06
|
| Hi,I tried to execute similar type of query like below....select SUB_STATUS = CASE WHEN SUB_STATUS = "A" THEN "Male" ELSE "Female" end CASE FROM subscriber;I got error "ORA-00923: FROM keyword not found where expected"???? |
 |
|
|
Vadivu
Starting Member
31 Posts |
Posted - 2008-05-08 : 08:15:39
|
| try removing the CASE keyword at the end... that is not needed in sql server |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-08 : 08:50:37
|
quote: Originally posted by toprasad Hi,I tried to execute similar type of query like below....select SUB_STATUS = CASE WHEN SUB_STATUS = "A" THEN "Male" ELSE "Female" end CASE FROM subscriber;I got error "ORA-00923: FROM keyword not found where expected"????
Tryselect CASE WHEN SUB_STATUS = 'A' THEN 'Male' ELSE 'Female' end as SUB_STATUS FROM subscriber;This is MS SQL Server ForumPost your question at Oracle forumswww.orafaq.comwww.dbforums.comMadhivananFailing to plan is Planning to fail |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-05-08 : 08:55:14
|
| As mentioned, this is not an Oracle forum, this is a SQL Server forum.However, for both products: you should have a tables of Genders or Sex, that has the 2 values (or more?) and the description. Then, you simply JOIN to your Sex table to get the description. This is the way databases are designed to be used; don't hard-code or embed descriptions or data in your SQL statements, store your data in your tables.see:http://weblogs.sqlteam.com/jeffs/archive/2006/02/10/9002.aspx- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
toprasad
Starting Member
4 Posts |
Posted - 2008-05-08 : 23:40:10
|
| Hi Madhivanan,This statement worked: select CASE WHEN SUB_STATUS = 'A' THEN 'Male' ELSE 'Female' end as SUB_STATUS FROM subscriber;Many thanksPrasad |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-09 : 02:39:34
|
quote: Originally posted by toprasad Hi Madhivanan,This statement worked: select CASE WHEN SUB_STATUS = 'A' THEN 'Male' ELSE 'Female' end as SUB_STATUS FROM subscriber;Many thanksPrasad
Thanks and keep in mind that you should post oracle related questions at ORACLE forums MadhivananFailing to plan is Planning to fail |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2008-05-12 : 02:25:10
|
| Hi,Verify thisSELECT name, case when sex = 1 then 'Male' else 'Female' End as 'sex' From empBe Cool.... |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-12 : 03:37:01
|
quote: Originally posted by raky Hi,Verify thisSELECT name, case when sex = 1 then 'Male' else 'Female' End as 'sex' From empBe Cool....
Please dont put quotes around column aliases |
 |
|
|
|