Solved

sql computed value syntax

Posted on 2007-03-28
4
251 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

Suggested Solutions

Title # Comments Views Activity
Access Query 4 46
2 Access tables, count verbiage used 6 31
How to convert sql code to access query 8 67
SQL Query resolving a string conversion issue 26 37
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…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now