Returns the value of column line

Greetings!  I currently have a request we will tell

SELECT value, period FROM MAS_CFUS_KEYACM_CONTROLDATA ORDER BY cf_keyword_ID

RESULTS

Period value

--------------------------

100.0002 1 JANUARY 14

-35.68 1 DECEMBER 14

-1943.67 NOVEMBER 1, 14

678.0013 OCTOBER 1, 14

This continues for about 15 results by cf_keyword_ID.

I'm looking to return the VALUE first in a new column called PREV1, the second value of PREV2, third in PREV3 and so on.  The same goes for the dates.  And all this for only the first 10 values of each cf_keyword_ID.  Can anyone suggest the best way to achieve this?

Thank you!!

Hello

This is called pivoting.  Because I don't have a copy of your table test, I'll use scott.emp to illustrate.

This shows the first 3 employees for each job, in order by hiredate, along with their hiredates:

WITH relevant_data AS

(

SELECT ename, job, hiredate

row_number () taken OVER (PARTITION OF work

ORDER BY hiredate

) AS r_num

FROM scott.emp

)

SELECT *.

OF relevant_data

PIVOT (MIN (ename) AS ename

MIN (hiredate) AS hiredate

FOR r_num (1, 2, 3)

)

ORDER BY job

;

Output:

WORK 1_ENAME 1_HIREDATE 2_ENAME 2_HIREDATE 3_ENAME 3_HIREDATE

--------- ---------- ----------- ---------- ----------- ---------- -----------

ANALYST FORD 3 December 1981 SCOTT April 19, 1987

The CLERK SMITH December 17, 1980, 3 December 1981 JAMES MILLER January 23, 1982

MANAGER JONES 2 April 1981 BLAKE 1 May 1981 CLARK June 9, 1981

PRESIDENT KING November 17, 1981

SELLER ALLEN 20 February 1981 WARD 22 February 1981 TURNER 08-Sep-1981

There are actually more than 3 SECRETARIES and SALESMEN.  Which does not cause an error; the only first 3 are shown.

As you can see, having less of 3 does not cause any errors, either.

For more info on pivots, see the FAQ of the Forum:

Re: 4. How can I convert rows to columns?

I hope that answers your question.

If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.

Explain, using specific examples, how you get these results from these data.

If yod post rather a problem using scott.emp, then you need not display the sample data; just results and explanations.

Always say what version of Oracle you are using (for example, 11.2.0.2.0).

See the FAQ forum:

Re: 2. How can I ask a question in the forums?

Tags: Database

Similar Questions

  • return the names of columns which line values are not null.

    Hi I m a new db admin guy, and I need a sql script that should return the names of columns of the given table. and the returned column must be the value (fyi - if the column contains the value null column name would not come to the o/p of sql).
    Exmple:
    name of the table - A
    fresh status s.no name brand
    1 null aa 45P
    paid 2 null bb 30
    3 cc paid 35P

    (FYI - 1) if I give the table name (A) and s. n. (2) o/p should be - name, mark.
    (2) if I give the status of tablename (A) and s. n (1) the o/p should be - name, brand.

    Thank you
    Krishna.

    Published by: user13294228 on June 14, 2010 22:54

    BTW,
    The previous solution is for all values of the column, if you want a specific line, you can add it in where clause.
    I mean in your example, it you look like:

    SET serveroutput on;
    
    DECLARE
       l_cnt          NUMBER;
       l_str          VARCHAR2 (255) := '';
       l_table_name   VARCHAR2 (255) := 'YOUR_TABLE_NAME';
       l_col_cond     VARCHAR2 (255) := 'S_NO';
       l_val          NUMBER         := 1;
    
       CURSOR c_col
       IS
          SELECT column_name
            FROM user_tab_columns
           WHERE table_name = l_table_name;
    BEGIN
       FOR i IN c_col
       LOOP
          EXECUTE IMMEDIATE    'SELECT COUNT ('
                            || i.column_name
                            || ') FROM '
                            || l_table_name
                            || ' WHERE '
                            || l_col_cond
                            || ' = '
                            || l_val
                       INTO l_cnt;
    
          l_str := l_str || CASE
                      WHEN l_cnt = 0
                         THEN ''
                      ELSE i.column_name
                   END || ',';
       END LOOP;
    
       l_str := SUBSTR (l_str, 1, LENGTH (l_str) - 1);
       DBMS_OUTPUT.put_line (l_str);
    END;
    

    Saad,

    Published by: S.Nayef on June 15, 2010 11:54

  • break the values of columns in separate lines

    Hello

    I have a query that returns the values of 4 columns of it. Of this, a column can have many values it contains separated by semocolon (-). The requirement now is if this particular column has more than one value, separated by the semocolon (-), then the query must return each of them separately as a new line and keep the rest, column values as common for each of these values of this colummn.

    For example, select...

    output:
    col1 col2 col3
    Risk of BB IE6 71 of the PACK_PWRMART file. DELETE_POSITION_WO_RISK ($FEEDINSTANCEID); PACK_PWRMART. DELETE_INSTRU_REL_POS_WO_RISK; QC 8401

    COL4
    2010-02-11 09:29:45 December 28, 2010

    Now, col3 has 3 values separated by (;). Therefore, the output of the query
    col1          col2                           col3( now split with 3 values)                                                          col4
    71     BB IE6 risk file     PACK_PWRMART.DELETE_POSITION_WO_RISK($FEEDINSTANCEID)        2/11/2010 9:29:45 AM 28-Dec-2010     
    72     BB IE6 risk file     PACK_PWRMART.DELETE_INSTRU_REL_POS_WO_RISK            2/11/2010 9:29:45 AM 28-Dec-2010     
    73             BB IE6 risk file             QC 8401                                                                                       2/11/2010 9:29:45 AM 28-Dec-2010
    The solution that I thought:

    I don't know if this can be achieved in a single SQL statement, so I thought I should write a block of code that will use the collection separate each of the value of this column and use some sort of record of object to insert the entire line in it 3 times (or the number of times as much as the values in this column) , but without success.

    Something like this:
    declare
    type feed_name is table of varchar2(4000);--feed_static.feed_description% type INDEX BY PLS_INTEGER;
    feed_nm feed_name;
    param_val feed_name;
    dat feed_name;
    feed_desc feed_name;
    str number;
    str1 varchar2(1000);
    begin
    select feed_description as "Feed Name" ,
           param_value as "Post_Proc Prarameter",
           '28-Dec-2010' as "COB date",
           ft.feed_type_description as "Feed Type"    
    BULK COLLECT INTO feed_nm,param_val,dat,feed_desc
    from feed_static fs, feed_parameter fp, feed_type ft 
    where fs.feed_id =fp.feed_id
    and fs.feed_type_id = ft.feed_type_id
    and fs.feed_type_id not in (4,15,16,25)
    and fp.param_name  = 'postproc'
    and fp.close_action_id is null
    and fs.feed_description in ('BB 0J0 risk file')--,'BB 1J1 risk file')
    order by  fs.feed_type_id,feed_description;
    FOR i IN 1..param_val.count
    loop
        select length((param_val(i))) - length(replace(param_val(i),';')) into str from dual;
               dbms_output.put_line(str); 
               for j in 1..str
                   loop
                        SELECT SUBSTR(param_val(i), 1 ,INSTR(param_val(i), ';', 1, j)-1) into str1 FROM dual;
                        dbms_output.put_line(str1); 
                        str1:=' ';
                   end loop;
    end loop;    
    end;
    But the "dbms_output.put_line (str1); does not give me o/p as required except the first value (assume thr are the 3 values of the column).
    Also I'm not sure of what I'm trying to do is in the right direction or not.

    I have not used any RECORDING still to poulate values separated again (I'm not sure about hoe to use)

    Cam anyone help me please with this code.

    Rgds,
    Aashish

    Try this:

    select feed_description as "Feed Name" ,
           param_value as "Post_Proc Prarameter",
           '28-Dec-2010' as "COB date",
           --ft.feed_type_description as "Feed Type" ,
           regexp_substr( ft.feed_type_description,'[^;]+',1,rown.seq)
    from feed_static fs, feed_parameter fp, feed_type ft, (SELECT LEVEL seq FROM DUAL
                        CONNECT BY LEVEL<=max(length(ft.feed_type_description)- length(replace(ft.feed_type_description,';'))))rown
    where fs.feed_id =fp.feed_id
    and fs.feed_type_id = ft.feed_type_id
    and fs.feed_type_id not in (4,15,16,25)
    and fp.param_name  = 'postproc'
    AND rown.seq<=(length(ft.feed_type_description)- length(replace(ft.feed_type_description,';')))
    and fp.close_action_id is null
    and fs.feed_description in ('BB 0J0 risk file')--,'BB 1J1 risk file')
    order by  fs.feed_type_id,feed_description;
    

    regexp_count started in 11g. It counts the number of models in a particular string. I replaced by length - length (repalce).
    You can replace the word 'max (length (ft.feed_type_description) - length (replace(ft.feed_type_description,';'))))' with 10 or 15, i.e. the maximum number of semicolons in the chain

  • change the color of line based on the value of column 5 Apex in the classic report

    Version of the apex 5.0.0.00.31

    Standard universal theme

    Page theme default template

    Classic report

    Foldable report template

    Hello

    I know this question has been asked several times here, but I'm working on 5 Apex and need to know the correct way to do it in this version.

    I need to change the color of the text of the entire line (no background color) based on the value in one of the columns of the classic report. I have just two conditions, if the value of column = Yes, color should be red, otherwise it must be green.

    I am new to jscript and css, so appreciate if someone can tell me the solution with steps.

    I have already checked this link that changes the value of the column, need to do something similar to the whole line.

    https://tylermuth.WordPress.com/2007/12/01/conditional-column-formatting-in-apex/

    Hi coolmaddy007-Oracle,.

    Here's an example set up on the apex.oracle.com according to the specifications you gave: https://apex.oracle.com/pls/apex/f?p=35467:1

    Version of the apex 5.0.0.00.31

    Standard universal theme

    Page theme default template

    Classic report

    Foldable report template

    Here is how it is done:

    Create a dynamic action with the following specifications:

    Name: Give the appropriate name

    Event: After refresh

    Selection type: region

    Region: select your region classic report

    Condition: No strings attached

    Action: Run the JavaScript Code

    Fire on loading the Page: Yes

    Code:

    $('td[headers="JOB"]').each(function() {
      if ( $(this).text() === 'MANAGER' ) {
        $(this).closest('tr').find('td').css({"color":"red"});
      }
      if ( $(this).text() === 'SALESMAN' ) {
        $(this).closest('tr').find('td').css({"color":"green"});
      }
      if ( $(this).text() === 'CLERK' ) {
        $(this).closest('tr').find('td').css({"color":"blue"});
      }
    });
    

    NOTE: Download the selector appropriate for your knowledge $('td[headers="JOB"]') case using firebug/browser development tools.

    Items concerned: leave blank.

    PS: Changed the example to change the color of text instead of the background color.

    I hope this helps!

    Kind regards

    Kiran

  • fatal error when installing master collection '[FATAL] installation - installation package error C:\Users\Desktop\MasterCollection_CS6_LS6\packages\core\PDApp.pimx. Returns the value of pim_installPackage = - 1

    Hello

    When I try to install a trial like photoshop cs6 or master collection cs6 product, I get the error "Installer has not initialized. I used Adobe cleaner to remove all products cs6 and tried again, but no luck, same error.

    I opened the log file and find this line:

    [FATAL] Setup error - installation package C:\Users\moshe-a\Desktop\MasterCollection_CS6_LS6\packages\core\PDApp.pimx.

    Returns the value of pim_installPackage = - 1

    No idea how to fix?

    Thank you, Momu

    start at the top and work your way down to apply applicable patches until your problem is solved.

    If (win) cc: https://helpx.adobe.com/creative-cloud/kb/creative-cloud-desktop-application-failed.html

    If your error is:

    "Setup failed to initialize. File not found. ' or 'could not initialize installation. This could be due to missing files.

    first of all, rename folder OOBE OOBE.old.

    to find the OOBE:

    Win 64 bit OS: Program Files x86\Common Files\Adobe\OOBE

    Win 32 bit OS: Program Files \Common Files\Adobe\OOBE

    Mac os: HD > library > application support of > adobe > caps

    Mac os: USER > library > application support of > adobe > OOB

    If it fails or isn't the exact error you see, uninstall, clean (http://www.adobe.com/support/contact/cscleanertool.html) and reinstall.

    If you use an installation dvd:

    Copy the contents of the drive in a desktop folder and install from this directory.

    If you are using a mac:

    1. try to create a new user account in Mac with administrator privileges.

    2. connect to the new user, navigate to Mac HD > Application > utilities > Adobe Installer folder, locate products such as Adobe Reader, Adobe Flash, Adobe Air and uninstall the

    3. navigate to the user library > Application Support > Adobe and Adobe put in the trash.

    4. navigate to Mac HD > library > Application Support > Adobe and Adobe put in the trash.

    5 restart the installation.

    If everything is applicable above fails, check your Setup logs:

    http://helpx.Adobe.com/Photoshop-elements/KB/troubleshoot-install-using-logs-elements.html

  • return two values of columns via Javascript

    For the same purpose as:

    OnClick = "$s ('P1_DEPTNO', #DEPTNO #); return false; »

    to return a value from column via javascript, is it possible to return 2 values? Example:

    OnClick = "$s ('P1_DEPTNO', #DEPTNO #); $s ('P1_EMP, #EMPLOYEE #); return false; »

    Thank you all :)

    Max

    Maxime Carrier wrote:
    Sorry for the wrong question form, I'm not an English speaker, so I try my best to make sentences clear.

    My goal is like this in this issue: Insert the value of a column in the report in a page with JavaScript element - 2?

    My Apex version is: 4.0.2.00.06
    My DB is: Oracle 11G
    My browser: IE 7

    I'm trying to save two values when I click on a link in a report. I will use these values in which the declaration of another report. The content of the second report will depend on the link I clicked in the 1st. It will change dynamically without reloading the entire page.

    Standard or interactive report?

    Where is the defined link? Column link IR? The column link? HTML embedded in the report query?

    One of the two values is not a number.

    Use quotes around chains of substitution of the column as shown above.

  • XML - ORA-19025: EXTRACTVALUE returns the value of a single node

    Hello

    I'm new to XML DB. Can someone help me with the below XML

    I use the following XML... (I pasted a part only of it coz I need data only up to this article)

    XML
    --------------------

    <? XML version = "1.0" encoding = "UTF-8"? > < SOAP - ENV:Envelope xmlns:SOAP - ENV = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-."
    example"container ="http://www.w3.org/2001/XMLSchema"> < SOAP - ENV:Body >
    < ns:PicklistWS_GetPicklistValues_Output xmlns:ns = "urn: crmondemand/ws/list dropdown /" >
    < ListOfParentPicklistValue xmlns = "urn: / xml/crmondemand/list of choices" >
    < ParentPicklistValue >
    < language > ENU < / language >
    < ParentFieldName > plProduct_Team < / ParentFieldName >
    < ParentDisplayValue > Marketing On Demand < / ParentDisplayValue >
    < ParentCode > Marketing On Demand < / ParentCode >
    < Disabled > N < / disabled >
    < ListOfPicklistValue >
    < PicklistValue >
    Escalation of OCP/SME < code > < code >
    Escalation of OCP/SME < DisplayValue > < / DisplayValue >
    < Disabled > N < / disabled >
    < / PicklistValue >
    < PicklistValue >
    Ask fusion < code > < code >
    Merge request < DisplayValue > < / DisplayValue >
    < Disabled > N < / disabled >
    < / PicklistValue >



    Code
    ---------




    SELECT distinct
    EXTRACTVALUE (value (SR), ' / ParentPicklistValue/ListOfPicklistValue/PicklistValue/Code ','xmlns = "urn: / crmondemand/xml/list of choices"') AS display.
    Return EXTRACTVALUE (value (SR),'/ ParentPicklistValue/ListOfPicklistValue/PicklistValue/DisplayValue ',' xmlns = "urn: / crmondemand/XML/picklist"'),.
    EXTRACTVALUE (value (SR), '/ ParentPicklistValue/ParentDisplayValue','xmlns = "urn: / crmondemand/XML/picklist"') AS parent_display,
    EXTRACTVALUE (value (SR), '/ ParentPicklistValue/ParentCode','xmlns = "urn: / crmondemand/XML/picklist"') AS parent_return
    TABLE (XMLSEQUENCE ((EXCERPT)
    WEB_SERVICE (' <? xml version = "1.0" encoding = "UTF - 8" standalone = "no"? > < envelope soap: xmlns:soap = "http://schemas.xmlsoap.org/soap/envelope/")
    xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" container = "http://www.w3.org/2001/XMLSchema" >
    < soap: Body >
    < PicklistWS_GetPicklistValues_Input xmlns = "urn: crmondemand/ws/list dropdown /" >
    Type < FieldName > < / FieldName >
    Service request < RecordType > < / RecordType >
    < / PicklistWS_GetPicklistValues_Input >
    < / soap: Body >
    "< / envelope soap: >.
    (' document / urn: crmondemand/ws/list dropdown /: ' GetPicklistValues, Id_de_la_session).
    "/: soap envelope / soap: Body / * / * / * ',' xmlns:soap ="(http://schemas.xmlsoap.org/soap/envelope/'))) SR "


    ERROR
    ---------

    ORA-19025: EXTRACTVALUE returns the value of a single node


    UNDERSTANDING
    ---------------------------

    As my Xpath only points until the node - ParentPicklistValue and not the child nodes under it. That's why, when I try to interview the child nodes - / ParentPicklistValue/ListOfPicklistValue/PicklistValue/Code, I get the error mentioned above.

    REQUIREMENT
    -----------------------

    Can someone help me to receive the values of the mother and child values based on xml and query above.

    Hello

    It's a classic ;)

    You need a second XMLSequence who shreds the collection of PicklistValue in relational lines:

    select extractvalue(value(sr2), '/PicklistValue/Code', 'xmlns="urn:/crmondemand/xml/picklist"') AS Display
         , extractvalue(value(sr2), '/PicklistValue/DisplayValue', 'xmlns="urn:/crmondemand/xml/picklist"') AS Return
         , extractvalue(value(sr1), '/ParentPicklistValue/ParentDisplayValue', 'xmlns="urn:/crmondemand/xml/picklist"') AS parent_display
         , extractvalue(value(sr1), '/ParentPicklistValue/ParentCode', 'xmlns="urn:/crmondemand/xml/picklist"') AS parent_return
    from table(
           xmlsequence(
             extract( WEB_SERVICE( ... )
                    , '/soap:Envelope/soap:Body/ns:PicklistWS_GetPicklistValues_Output/ListOfParentPicklistValue/ParentPicklistValue'
                    , 'xmlns="urn:/crmondemand/xml/picklist"
                       xmlns:ns="urn:crmondemand/ws/picklist/"
                       xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' )
           )
         ) sr1
       , table(
           xmlsequence(
             extract( value(sr1)
                    , '/ParentPicklistValue/ListOfPicklistValue/PicklistValue'
                    , 'xmlns="urn:/crmondemand/xml/picklist"' )
           )
         ) sr2
    ;
    

    What is your version of the database BTW?
    10.2 and upward, you can use the XMLTable.

  • Do stuff to PL/SQl that returns the value and redirect to modal page by setting this value

    Hello

    a button click Page1 I would perform a PL/SQL procedure that returns a value in P1_ITEMVAL and then redirect to a page 2 (modal page) and the value of an item on this page with the value previously returned. To do the same thing with a normal page is quite easy:

    Button action is present, then process of PL/SQL that returns the value in the P1_ITEMVAL element and, finally, a branch at page 2 that sets P2_ITEMVAL with P1_ITEMVAL. I really have no idea how to do the same thing when the target is a modal page.

    I created a unit test on https://apex.oracle.com/pls/apex (application 1554 - redir_to_modal)

    Workspace: tests

    USER: supporter

    PWD: supporter1234

    Any help would be much appreciated.

    Kind regards

    Pavel

    Pavel

    If you prepare a URL using the value calculated in the PLSQL of DA part you can then use a subsequent stage of javascript to set the location of the window.

    This will jump to the top of the page of the modal dialog box

    : P1_URL: = apex_util.prepare_url)

    ' f ? p ='|| : APP_ID - Application id

    |': 2' - Page id

    ||': ' || : APP_SESSION - Session id

    ||':'                      -- Request

    ||':NO'                    -- Debug

    : ': ' - Clear Cache

    : ': ' - Settings

    ||' P2_ITEMVAL'

    : ': ' - Parameter values

    || (: P1_ITEMVAL);

    then in the action of javascript

    Window.Location.Replace ($v ('P1_URL'));

    Hope this is of some use

    Concerning

    Kelvin

  • Request to remove row where the value of column contains alphabets

    Hello

    Could someone please help me to get this application working.

    Request to remove row where the value of column contains alphabets.

    DELETE FROM BIN_ITEM WHERE order_nmb LIKE '% [A - Z] % ' | LIKE '% [a - z] %'

    Thank you and best regards,

    Madam.

    SELECT order_nmb FROM BIN_ITEM WHERE regexp_count(order_nmb,'[0-9]') = 0

    ----

    Ramin Hashimzade

  • Mathmatical function to return the value in injectors

    Hello
    I have obliged. If value for ex Lake 4400000, he should return as 4.4millions even for billions.
    is there an oracle function to return the value in this format. ???

    Hello

    When I want to have a "readable" released in large numbers, I use to do the following:

    Scott@my11g SQL>with t as (
      2  select 3456123456 n from dual
      3  union all select 4567123 from dual
      4  union all select 123465 from dual
      5  )
      6  select n, case when n>1000000000 then trunc(n/1000000000,1)||' Billions'
      7  when n>1000000 then trunc(n/1000000,1)||' Millions'
      8  else to_char(n) end fmtn
      9  from t ;
    
             N FMTN
    ---------- -------------------------------------------------
    3456123456 3.4 Billions
       4567123 4.5 Millions
        123465 123465
    

    ------
    * + [change] + *.
    Moreover, lakh [url http://en.wikipedia.org/wiki/Lakh] has no meaning outside of South Asia.
    Especially for a French man like me, grown with [url http://en.wikipedia.org/wiki/International_System_of_Units] International system of units that is fighting against what I call "funky" measures empirical such miles, yards, feet, inches, just not multiple of 10³
    Same billion mean differ depending on the country (see [url http://en.wikipedia.org/wiki/Long_and_short_scales] long and short scales)

    Just for "fun": [url http://articles.cnn.com/1999-09-30/tech/9909_30_mars.metric.02_1_climate-orbiter-spacecraft-team-metric-system?_s=PM:TECH] this is what can happen when we do not use the same system of units.

  • How to return the value 0 for no data using the County?

    Hi all
    I used this query to count the number of records for each month of the year:

    SELECT DISTINCT COUNT (I.information_sid) COUNT, TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM') MONTH

    INFORMATION I

    TO_DATE GROUP (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    ORDER BY TO_DATE (TO_CHAR (INSERT_DATE, 'MM'), 'MM')

    But this code returns no value for months without data
    I want to return the value '0' for any month of data. How, please?

    Note: I use reports 6i.

    Maybe this?

    SELECT SUM(CNT_REC) CNT_REC, MONTH
    FROM
    (
    SELECT COUNT(I.information_sid) CNT_REC, TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM') MONTH
    FROM INFORMATIONS I
    GROUP BY TO_DATE(TO_CHAR(INSERT_DATE,'MM'),'MM')
    UNION ALL
    SELECT 0, LPAD(ROWNUM,2,0)
    FROM ALL_OBJECTS
    WHERE ROWNUM <= 12
    )
    GROUP BY MONTH
    ORDER BY MONTH
    

    No need to SEPARATE during the use of GROUP BY.

    -Clément

  • DICOM metadata - extractvalue returns the value of a single node

    Hello

    I have difficulties in getting the value of the objects with repeated elements. Specifically, I need to get the value of spacing of pixels in the following excerpt from xml.
    <DICOM_OBJECT>
    ..
         <DECIMAL_STRING tag="00181063" definer="DICOM" name="Frame Time" offset="900" length="2">0.0</DECIMAL_STRING>
         <CODE_STRING tag="0018106A" definer="DICOM" name="Synchronization Trigger" offset="910" length="10">NO TRIGGER</CODE_STRING>
    ..
         <DECIMAL_STRING tag="00280030" definer="DICOM" name="Pixel Spacing" offset="1660" length="22">0.003562</DECIMAL_STRING>
         <DECIMAL_STRING tag="00280030" definer="DICOM" name="Pixel Spacing" offset="1660" length="22">0.003562</DECIMAL_STRING>
         <UNSIGNED_SHORT tag="00280100" definer="DICOM" name="Bits Allocated" offset="1690" length="2">8</UNSIGNED_SHORT>
        <UNSIGNED_SHORT tag="00280101" definer="DICOM" name="Bits Stored" offset="1700" length="2">8</UNSIGNED_SHORT>
    ..
    </DICOM_OBJECT>
    Normally, I use the following query to get the value of spacing of pixels:
     select EXTRACTVALUE(t.dicom.metadata
                          ,'/DICOM_OBJECT/*[@name="Pixel Spacing"]'
                         ,'xmlns=http://xmlns.oracle.com/ord/dicom/metadata_1_0')  scale_factor
       from my_dicom_object t
    It works, but not when there are two elements. Then I get the error: "ORA-19025: EXTRACTVALUE returns the value of a single node.


    All I really need is to get the value of the first node with the name of "spacing of pixels. Despite the many examples available to do with traditional xml paths, I was unable to find an example that makes using XPATH search strings rather than direct tag structure.

    Can someone give an example?

    Thank you!

    Published by: rcdev on August 10, 2009 15:20

    All I really need is to get the value of the first node with the name of "spacing of pixels.

    This? :

    select EXTRACTVALUE(t.dicom.metadata
                          ,'/DICOM_OBJECT/*[@name="Pixel Spacing"][1]'
                         ,'xmlns=http://xmlns.oracle.com/ord/dicom/metadata_1_0')  scale_factor
       from my_dicom_object t
    
  • Coverting a line in the values in columns

    Hi friends Expert SQL,

    I have a line that contains 6 columns where I want the data to appear in the form of columns, as shown here:

    From:

    Select item1, item2, item3, amt1, amt2, amt3 in item_table, when sno = 1; <-returns 1 row as below

    ITEM1 ITEM2 ITEM3 AMT1 AMT2 AMT3
    ---------- ------------ ------------- ----------- ------------ ----------
    AAA BBB CCC 10,00 20,00 15,00


    Explanation of data: item1 (AAA) price is amt1 (10.00), item2 (BBB) price is amt2 (20 h 00) and item3 (CCC) price is amt3 (15.00). Ok.

    Now I want that data to be converted to columns, as shown here:

    TO:

    AMT ELEMENTS
    --------- ---------
    AAA 10.00
    BBB 20.00
    CCC 30.00


    Please help me guys, I want a SQL to display these data.

    I found a single query that converts a row of columns, but this is not my requirement: [for your reference only]

    SQL > select substr (the_string
    , decode (level, 1, 1, instr(the_string,',',1,level-1) + 1)
    , decode (instr(the_string,',',1,level), 0, length (the_string), instr(the_string,',',1,level) - decode (level, 1, 0, instr(the_string,',',1,level-1))-1)
    ) the_value
    from (select (select item1 |)) «, » || Item2. «, » || Item3 item_table where sno = 1) ELEMENTS
    the double)
    connect by level < = length (the_string) - length (replace(the_string,',')) + 1


    Thank you and best regards,
    Kiran
    WITH pivot_data
         AS (SELECT 'AAA' ITEM1,
                    'BBB' ITEM2,
                    'CCC' ITEM3,
                    '10.0' AMT1,
                    '20.0' AMT2,
                    '15.00' AMT3
               FROM DUAL)
    SELECT t1.items, t.amount
      FROM (SELECT NULL items, amount, ROWNUM rn
              FROM pivot_data UNPIVOT INCLUDE NULLS (amount
                              FOR items
                              IN (AMT1, AMT2, AMT3) )) t,
           (SELECT items, NULL amount, ROWNUM rn
              FROM pivot_data UNPIVOT INCLUDE NULLS (items
                              FOR amount
                              IN (ITEM1, ITEM2, ITEM3))) t1
     WHERE t.rn = t1.rn
    
    ITEMS     AMOUNT
    AAA     10.0
    BBB     20.0
    CCC     15.00
    
  • Add the value of column based on a different line with the same id

    Hello world

    I have a query that displays the first three columns of the table below. I would like to add a column to this output, most indicating (for each row) if there is an electronic product in the same order. For example, the command 1 in the table below contains 1 unit of furniture and 1 unit of electronics. In my outings, I would add a flag 'Y' for the two rows 1 and 3. Also, I would add a "N" indicator to any order which does contain all the electronics.

    Any ideas on how to achieve this? Any idea or suggestion is appreciated!

    order_id product_cat quantity with_electronics
    1furniture1THERE
    2grocery1N
    1Electronics1THERE

    Thank you

    Zsolt

    Hi, Zsolt,

    You can also use analytical functions.  For example:

    SELECT order_id, product_cat, quantity

    MAX (CASE

    WHEN product_cat = 'electronics '.

    THEN 'Y '.

    ANOTHER "N".

    END

    ) OVER (PARTITION BY order_id) AS with_electronics

    Orders

    ;

    Of course, I can't test it without a table.

  • Returns the selected table column header

    I don't know there is probably a way to do this.  But I have not yet found.

    I am building an application that will act as a sort of "universal" reports generator for a MySQL database tables.

    At startup, a drop-down list box is filled with the names of tables in the database.  When the user selects one of these tables, the column names are taken from the base and used to fill the column headers for the table of LabVIEW.

    The idea is that the user can select this column and enter the constraints of filter in a text box.  These constraints will then be added to the WHERE statement for this column.

    So far I've been able to find a way to return the Active cell or a selection of cells, when the user clicks on the actual data of the table.

    Is there a direct way to retrun a selected in LabVIEW column header value?

    I am dreaming that there may be some sort of workaround using transparent controls over the headers.  But because different tables will have a different number of columns that the user defines the width, I'm not really sure that it will work more.

    If you the editable headers, this allows Active cells specify that your column is - 1 column selected active line is the selected column. You may need to use the mouse down? to filter the possibility for the user to change the right column headings.

Maybe you are looking for

  • The amount of lines of advance cuando hago con scroll configurar como el mouse?

    I have the option of "Smooth scrolling" activada como siempre the tuve. Don't Sin embargo, cada vez as quiero hacer scrolling en firefox, no avanza una determinada amount of lines, sino as lo hace of pagina en pagina, y pierdo el rastro of what iba g

  • Firefox Download Manager problems

    The default in Firefox Download Manager began to show strange behavior today: no matter what file I try to download (in the default \download folder or in a folder chosen by me) is actually downloaded by the browser, but the file download status bar

  • Why my desktop Windows 8 used computer to connect to my wifi network

    Hello. I just bought my desktop computer November 28, 2012, so his 4 months of my date. My computer is a HP Pavilion p7-1449. The only problem ive a is when I tried to put my Mcafee on my Pc... I deleted my Norten because my trial had taken end. I wa

  • HP Officejet 4620: HP 4620 cannot use recharged HP cartridges

    I can't use HP Officejet 4620 reloaded cartridges I bought at Costco. I don't know if it is because of the update of the firmware HP snuck in front of me.  If this is the problem is it possible to cancel the firmeare update?  I'm $50 such what.

  • Cannot install the update of security for Vista (kb2479943).

    I get the error code 80070643. tried to repair of .net framework windows suggestions. for the two sp1 3.5 and 4. I also uninstalled and reinstalled the .net Framework. I run microsoft 2007 office. any help on what I can do to get this security update