Do we not have an oracle function to select the non-null columns at the beginning

Hello

I have 8 columns. Some of them may be null.

I want to display all 8 columns in my result. Columns not null will be first and no one at the end.

Here is an example of data:

Employee table:
 Employee_id   Emp_fname  emp_lname  emp_mname  dept salary emp_height  emp_weight
   1               aaa        ddd                d1   100      6           180
   2               bbb                ccc             120                 169
   3               dfe                           d2            5.9         223
The expected result is:
result1 result2   result3 result4  result5  result6 result7 result8
1        aaa        ddd     d1       100     6        180
2        bbb        ccc     120      169
3        dfe        d2      5.9      223
Thank you.

Published by: BluShadow on July 12, 2012 16:12
addition of {noformat}
{noformat} tags for readability.  Please read {message:id=9360002} and do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

945559 wrote:
I'm using Oracle Database 11 g Release 11.2.0.3.0.

Here is my sample data.

CREATE TABLE saleshist (product VARCHAR2 (30), q1 NUMBER NUMBER of q2, q3 NUMBER, NUMBER of T4);
INSERT INTO saleshist VALUES ('EE Oracle', 100, 123, null, 128);
INSERT INTO saleshist VALUES (null, 'Partitioning', 100, 130, 128);

desired output:
col1, col2, col3 col4
'Oracle EE', 100, 123, 128, null
"Partitioning", 100,130,128, null

It seems that you have 4 column headers, but 5 columns.

Assuming that the character ' ~' never occurs in one of the columns:

WITH   got_list           AS
(
     SELECT     '~' || product
          || '~' || TO_CHAR (q1)
          || '~' || TO_CHAR (q2)
          || '~' || TO_CHAR (q3)
          || '~' || TO_CHAR (q4)     AS list
     FROM    saleshist
)
SELECT  REGEXP_SUBSTR (list,  '[^~]+', 1, 1)     AS col1
,       REGEXP_SUBSTR (list,  '[^~]+', 1, 2)     AS col2
,       REGEXP_SUBSTR (list,  '[^~]+', 1, 3)     AS col3
,       REGEXP_SUBSTR (list,  '[^~]+', 1, 4)     AS col4
,       REGEXP_SUBSTR (list,  '[^~]+', 1, 5)     AS col5
FROM    got_list
;

Output:

COL1            COL2       COL3       COL4       COL5
--------------- ---------- ---------- ---------- ----------
Oracle EE       100        123        128
Partitioning    100        130        128

If you need a multiple character string, such as '? ~', to delimit the columns, then the same basic approach works, but the regular expression is messier.

Product is just another column in this solution. Can be NULL, and it doesn't have to be unique.

Tags: Database

Similar Questions

  • Windows 7 laptop market not have symbols of function keys on the laptop screen.

    Hello

    I was ondering w if someone can help me. I installed windows 7 on my laptop which is a MSI Wind U100 and before that I did when I press a function key symbol appears on the screen. But now when I press the function key no symbol doesn't appear on the screen of my laptop. I was wondering if someone could help me because its annoying and I cannot see how my volume is upward or down or both my shine.

    Someone please help me and explain what I need to do.

    Thank you very much!!!

    Hello

    You may need to update the drivers and utilities for your laptop with Windows 7 drivers, and check if the function is to return. Link from the manufacturer:

    http://www.msi.com/index.php?func=nbdriver&maincat_no=135&prod_no=1474&driver_os_no=1#OS

    Hope this information is useful.

    Amrita M

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • XMLFile parameter is not supported by Oracle APEX, please use the setXMLFile() method

    "XMLFile parameter is not supported by Oracle APEX, please use the setXMLFile() method.

    I created a test web app in apex.oracle.com to try a few things. I created a Flash 2D pie chart in a Web page, and it seems to make very well. But before rendering, I get the error message above, on the region of graph for 1-2 seconds.

    Can anynone tell me what means the error message above and why I'm getting this. I do not use a custom XML part. Has not changed the default settings of the chart area.

    I could see above the error appearing clearly since the apex.oralce.com is so slow... and graphics region takes awhile to load. Otherwise I could not have noticed. It happens in the IE8 and Google chrome.

    Oralce Apex 4.2.5.00.006 (https://apex.oracle.com)

    Google Chrome 34.0.01847.116

    Internet Explorer 8.0.6001.19518

    Can anyone help please. I'll try to become a test application setup dispalying this awhile earlier error message.

    I used HTML5 graphics in apex 4.2.0.00.27 in my office in my real application workspace. Most of my users still use IE8. HTML5 graphics all appeared well in their IE8 browser. One fine day, some parameters must be changed by my network administrator or soemthing else could have happened. I have no idea. My webapplication HTML5 graphics disappear IE8 users. IE9 users had no problem. I contacted our IT support staff of any changes to security settings that day, or earlier. Absolutely no help from my frustration. I have to change maps of my application (only about 6 of them) to the Flash graphics to overcome this obstacle. This is the story behind why I use Flash cards. If anyone has experienced a similar problem in IE8 HTML5 graphics please shed any light for me... This problem may be nothing to do with the "XMLFile parameter error message', but I'm not sure.

    You strike again BUG introduced with Oracle Application Express 4.2.5

    http://www.Oracle.com/technetwork/developer-tools/Apex/application-express/Apex-425-known-issues-2186292.html

    18601802 - ANYCHART XMLFILE WARNING DISPLAYED BEFORE FLASH GRAPHICS RENDERING when Flash graphics that take a long time to make, the user can see the following warning message appears briefly "XMLFile parameter only is not supported by Oracle APEX, please use setXMLFile() method.» The table will be always delivered. Solution: Please advise end-users to ignore the message.

  • CMDGW_CAT:3441: ERROR: can not have more than 3 entries in the LIST RACCESSPOINT

    Hello
    I have Tuxedo 8.1 in HP - UX.


    In the section of my dmconfig that I have:

    ....
    .....

    SERVICEF LDOM = DOMLOCAL RDOM = WTC1, WTC2, WTC4 WTC3
    .....
    .....

    I have this error when I tried to compile with dmloadcf y dmconfig:

    Invalid value
    CMDGW_CAT:3441: ERROR: can not have more than 3 entries in the LIST RACCESSPOINT
    CMDGW_CAT:1546: ERROR: dmloadcf: above the errors found during the syntax check

    increase the value of the parameter RDOM plus 3?
    How?

    Thank you...

    Hello

    Syntax:

    Service LDOM = local_domain RDOM = dom1, dom2, dom3

    sets the remote domains of failover for this particular import. It is not intended to provide access to a service in several areas. What you want, it's basically what you were doing, i.e.,.

    Service LDOM = local_domain, RDOM = dom1, dom2
    Service LDOM = local_domain, RDOM = dom2, dom3
    Service LDOM = local_domain, RDOM = dom3, dom4
    Service LDOM = local_domain, RDOM = dom4, dom1

    It would provide balance between the 4 areas and always provide areas of failover, although assigned to the ON_STARTUP linking strategies, then the following is sufficient:

    Service LDOM = local_domain, RDOM = dom1
    Service LDOM = local_domain, RDOM = dom2
    Service LDOM = local_domain, RDOM = dom3
    Service LDOM = local_domain, RDOM = dom4

    As only active areas will be used and those inactive is ignored.

    Kind regards
    Todd little
    Chief Architect of Oracle Tuxedo

  • I got a viral message, but do not have open it or click on the links - although he appeared in the 'View' menu, the PC is still safe?

    I got a viral message, but do not have open it or click on the links - although he appeared in the 'View' menu, the PC is still safe?

    the PC is still safe? "

    Probably yes. To be sure run a scan full anti-malware.
    https://support.Mozilla.org/en-us/KB/troubleshoot-Firefox-issues-caused-malware#w_how-do-i-get-rid-of-malware

  • Can I use your Apple TV when I do not have a modem, and I use the Wifi in the hotel room?

    Can I use your Apple TV when I do not have a modem, and I use the Wifi in the hotel room?

    Thank you!

    Probably not, but depends on the hotels wifi access. most of the hotels that I stay in you will have to "login" via web browser and the ATV doesn't have access to any browser...

    your best bet would be to broadcast directly from a mobile device connected to the tv in your hotel via a HDMI adapter...

  • I formatted and reinstalled xp to correct some problems and my multimedia audio and video vga drivers were lost. I do not have a CD with info and the Add Hardware Wizard cannot find the drivers. How can I fix it?

    I formatted and reinstalled xp to correct some problems and my multimedia audio and video vga drivers were lost. I do not have a CD with info and the Add Hardware Wizard cannot find the drivers. How can I fix it?

    You may be able to download the drivers from the web site of the manufacturer of the computer.

  • I do not have 'PhoneGap Build service' tab of the site in the cc of DreamWeaver? What should I do?

    I do not have 'PhoneGap Build service' tab of the site in the cc of DreamWeaver? What should I do?

    Go directly to the website phone Gap building.

    Adobe Build PhoneGap

    DW can't stay with fast cycle updated phone Gap.

    Nancy O.

  • 2015 Dreamweaver does not have ready php functions (insert, delete and select)

    Hello all the dreamweaver configuration is correct, but when I use the ready functions insert, select, delete, login (php in the database) does not work, I tried everything already and what works is to do it manually. What can you do for me?

    See here http://www.dmxzone.com/go/21842/enable-server-behaviors-and-data-bindings-panel-support-fo r-dreamweaver-cc

  • Oracle function to retrieve the records randomly

    I need function to select a random DB folder.

    For example, we have 500 records and an input to the function value is 5 ways, it must display the records randomly between 1 to 5

    Thank you

    Question is not clear, I thought that Oracle has always returned entries in random order... Do you expect the number of records between 1 & 5?

    Kind regards

  • A DBA how to set permissions so that its users can submit to its form but do not have to execute queries or touch the database?

    Original title: InfoPath/SQL

    I am familiar with InfoPath, but I'm a DBA to a database on SQL server. The person created the infopath form and there users who can submit to the form, however, the only ones who can submit to the form are those who have access to SQL. A DBA how to set permissions so that its users can submit to its form, but do not have access to run queries or press my database. Thank you

    Ask the question in the SQL Server forums:
    http://social.msdn.Microsoft.com/forums/SQLServer/en-us/home?category=SQLServer

  • Hello! I bought Lr 6 today but later got to know that there is mention of this in my adobe account. does not have a serial number is also. the money was also not deducted my Cardinal, Hi! I bought Lr 6 today but later fact knowledge that there was a discu

    Hello! the most bizarre thing that's happened today. I bought Lr 6 to Adobe.com / in and downloaded. At the time of installation, he asked for a serial... No. I have no Adobe. Although the money was deducted from my account (I got a message saying that). After talking to some people about it... I was told that I have not can bought a Lr 6 update since I have Lr 4.4 and I could update from Lr 5 to Lr 6 and not Lr 4.4 to Lr 6. Later in the evening after that I spoke with the people at adobe they told me that there was no transaction made by my account. I checked with the Bank to check the status of my card... money is not deducted. My question how come I could download it? At the time of installation, was asked for a serial no which I did not. What should I do with the 6 Lr downloaded on my laptop? Should I delete it and go through the download again? I'll be able to download Lr 6 just after 4.4 Lr or I have to buy Lr 5 and then again to buy Lr 6? Thank you.

    It is surprising that the Adobe staff did you not directly on the updated versions of Lr; the fact is that it is possible to update any version, starting by v1 to v6 bypassing versions between the two, and you download the upgrade even regardless of the installed version of Lr. Download, you did was very probably the trial version. It is not necessary to uninstall the copy of Lr v6 on your laptop at the moment, and if you manage to buy Lr, all you need to do are to enter your serial number purchased in the box for serial number, as found in the Help menu.

    For the rest of your problem, the only suggestion I can do unfortunately, must return to Adobe support.

  • 11 PE will not complete the rendering process, and I did not have orange bars more work in the timeline.

    Short video, PC 7, 64 bit, i5 w / 1 T. help?

    krisrsk9

    I dug in the screenshots.

    I still want to see what looks like the project after export to define the scope of the problem. That would say a lot.

    Development of automatic generation of files Preview 1.vulnerability

    When you return a timeline content with its orange line (or red) above it, the program automatically generates the preview files. These files are the same if you return a still or video. In the case of HD, these are files MPEG2.mpeg 960 x 540 @ 29.97 progressive frames per second. Each of them comes with a companion .xmp file. The overall contribution of each may be at least 8 MB. They add up quickly and must be aimed at a disk space hard with enough free space to accept.

    Often, the program works best if all the disks scratch are directed to the same place, namely external hard drive (formatted NTFS) with all the space I have escaped.

    a. where the media Cache is made? What to do in the same place as the others. Recording location of audio previews in line are defined in Edit Menu/preferences/Scratch disks. The location of the project record is defined in the new project dialog box.

    If I remember, somewhere, you said that the Scratch disks are directed to a location with only 50 GB of free space on the hard disk. Is this correct? This could be a point of focus.

    Update 2. Properties of these .mp4 and .mov files.

    I would like to get a sample of each. Any chance you could post those samples so that I have them test in Premiere Elements?

    The above is my last thought on this. At the moment I'm not buy in corrupted files.

    Later.

    Thank you.

    RTA

  • You do not have enough disk space to create the database...

    Hi all

    During the creation of the database, I received this message:

    + "You don't have enough disk space to create the database. +
    + You must at least 939008 on/U01 KB, you only 1981480960 available KB. +

    + Please allow more free disk space. » +

    I checked:
    Root@server# df h
    Size of filesystem used avail capacity mounted on
    / dev/dsk/c4t600A0B800033696A000017534E2F6F67d0s0
    2.2 T 2.2 G 2.2 T 1% / U01

    My Info:
    DB-INSUP2-C2VAS of SunOS 5.10 Generic_142909-17 sun4u sparc SUNW, Sun-Fire-V890
    Oracle database: 10.2.0.1


    Help, please!
    Thank you!
    Dan.

    Thank you all,

    I got the same warning messages and I created the point of editing/U01 with 50 GB for installation of Oracle and creation of database with no caveat. In my opinion, the warning appeared as the point of Assembly/U01 is too large (2.2 T).

    Sorting.

    Published by: hqtri on August 4, 2011 23:33

  • I do not have a tab in firefox at the top left

    I just downloaded firefox for the first time and I don't have a tab in firefox at the top left as the photo exhibit

    See also:

Maybe you are looking for