Solved

sql computed value syntax

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

17 Experts available now in Live!

Get 1:1 Help Now