Solved

sql computed value syntax

Posted on 2007-03-28
4
252 Views
Last Modified: 2010-05-19
Hi,

I want something like

select field1, field2, (field1 is field1 is not null else field2) from mytable

how do I say it correctly?

Thank you.
0
Comment
Question by:kerzner
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mukhtar2t
ID: 18810509
select field1,field2,nvl(field1,field2) from mytable
0
 
LVL 4

Accepted Solution

by:
mukhtar2t earned 500 total points
ID: 18810514
That is for Oracle
for mysql
select field1,field2,ifnull(field1,field2) from mytable
0
 
LVL 1

Author Comment

by:kerzner
ID: 18810548
and this is for sqlserver, which I happened to need

CASE WHEN destid is null Then 0  Else 1 End
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18811531
select field1, field2, COALESCE(field1 , field2) from mytable
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question