Avatar of AmmarDJ
AmmarDJ

asked on 

Data extraction

Hi.

I am extracting some data from the database.

Theses are four fields i.e. value field1,value field2,value field3,value field4 and the fifth field just carries the unit.

I want that if the value fields are blank it should not report anything. In this case it reports a unit.

And if the value field has a value it should report the value as well as the unit.

How to do it?

  value field1||'~'||unit field ||','||
  value field2  ||'~'||unit field ||','||
   value field3  ||'~'||unit field ||','||
    value field4 ||'~'||unit field ||','||
    unit field||','||
Oracle DatabaseDB Reporting Tools

Avatar of undefined
Last Comment
johnsone
Avatar of Rindbaek
Rindbaek
Flag of Denmark image

if you want to exclude rows where values 1 to 4 all are empty (null) add a where clause

where
value field 1 is not null AND
value field 2 is not null AND
value field 3 is not null AND
value field 4 is not null
Avatar of AmmarDJ
AmmarDJ

ASKER

Rindbaek can i use a where clause in a script like the one attached.
instrumentcsv.sql
Avatar of Rindbaek
Rindbaek
Flag of Denmark image

you already have one...

WHERE system = '77';

try:
WHERE system = '77' AND
value field 1 is not null AND
value field 2 is not null AND
value field 3 is not null AND
value field 4 is not null ;
ASKER CERTIFIED SOLUTION
Avatar of johnsone
johnsone
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of AmmarDJ
AmmarDJ

ASKER

Johnsone.

Thanks for the feedback.

regarding the nvl function, sounds a a good solution.

But i guess it will report a "null" if there is a null value. What if i just want to report a blank and not "null"

Regards
Avatar of johnsone
johnsone
Flag of United States of America image

Change the null at the end of the nvl2 statement to anything you want.  Since you are doing string concatenation, if it is null, there is nothing to concatenate.
Oracle Database
Oracle Database

Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.

81K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo