Solved

Pick not null names

Posted on 2014-01-09
4
362 Views
Last Modified: 2014-01-13
How can i do this.


Name1 Name2 Name3  Name4

ABC          CDE    BBB

                                          KKK

                            MBC        LLL


So pick UP First non null name staring from Name 1,2,3,4

Final name
ABC
KKK
MBC
0
Comment
Question by:sam2929
  • 2
4 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 39770082
Check out coalesce:

select coalesce(name1,name2,name3,name4) from sometable;
0
 
LVL 10

Expert Comment

by:HuaMinChen
ID: 39770098
Use
...
where nvl(Name1,'')<>'' or nvl(Name2,'')<>'' ...

Open in new window

0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39770104
HuaMinChen,

Your post doesn't make sense.

First piece that is wrong is that NVL(name1,'') doesn't do anything. An empty string in Oracle is considered a null so what that says is that if name1 is null, return null.

Second:
Given the data provided, please explain how your post will produce the expected results posted of:
Final name
ABC
KKK
MBC
0
 
LVL 31

Expert Comment

by:awking00
ID: 39771255
Coalesce was designed precisely for this kind of query. It simply says return the first non-null value reached (null if all values are null). You should close this question and award slightwv the points without delay.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to recover a database from a user managed backup
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

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

18 Experts available now in Live!

Get 1:1 Help Now