 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
tony Guest
|
Posted: Sat Aug 14, 2004 1:18 pm Post subject: sql translation pls. |
|
|
I have a SQL in MS Access read as :
select fielda, iif(fieldb=0, fieldc,fieldb)
from tableA
How could I do the same in Oracle? I tried NVL but no luck.
Thanks in advance.
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Sat Aug 14, 2004 1:43 pm Post subject: Re: sql translation pls. |
|
|
tony wrote:
| Quote: | I have a SQL in MS Access read as :
select fielda, iif(fieldb=0, fieldc,fieldb)
from tableA
|
A standard SQL alternative is to use Union, which Oracle should handle:
select fielda, fieldc
from tableA
where fieldb=0
union all
select fielda, fieldb
from tableA
where fieldb<>0
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
SpaceShipOne; GovernmentZero
|
|
| Back to top |
|
 |
Eric Hill Guest
|
Posted: Sun Aug 15, 2004 12:18 am Post subject: Re: sql translation pls. |
|
|
If you want to use the "Oracle" way, then...
select fielda, decode(fieldb,0,fieldc,fieldb)
from tableA
|
|
| Back to top |
|
 |
tony Guest
|
Posted: Sun Aug 15, 2004 3:43 am Post subject: how about iif(fielda>0, fielda, fieldb)? |
|
|
Sorry I am asking for more!
how about iif(fielda>0, fielda, fieldb)?
Thanks
| Quote: | If you want to use the "Oracle" way, then...
select fielda, decode(fieldb,0,fieldc,fieldb)
from tableA
|
|
|
| Back to top |
|
 |
Eric Hill Guest
|
Posted: Sun Aug 15, 2004 5:47 am Post subject: Re: how about iif(fielda>0, fielda, fieldb)? |
|
|
| Quote: | Sorry I am asking for more!
how about iif(fielda>0, fielda, fieldb)?
Thanks
|
decode(sign(fielda),1,fielda,fieldb)
Eric
|
|
| Back to top |
|
 |
Dmitry Arefiev [gs-soft.r Guest
|
Posted: Mon Aug 16, 2004 2:23 pm Post subject: Re: how about iif(fielda>0, fielda, fieldb)? |
|
|
And so on ? <g>
If Oracle version is >= 9, then you can use CASE statement.
| Quote: | select fielda, iif(fieldb=0, fieldc,fieldb)
from tableA
|
will be
select fielda, case when fieldb = 0 then fieldc else fieldb end
from tableA
Regards,
Dmitry
--
Dmitry L. Arefiev, gs-soft Company, http://www.gs-soft.com
Personal - http://www.da-soft.com
SAPx - Delphi to SAP R/3 direct access
Saphir - SAP R/3 metadata on your fingertips
MetaBase - ERWIN model in Delphi applications
NCOCI8 - Freeware Delphi to ORACLE direct access
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|