Solved

sql computed value syntax

Posted on 2007-03-28
4
254 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 143

Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

751 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