Need to obtain the result in an orderly manner

Hello!!

I had used this querry

select
func_find_busfun_desc('MEL', apbuf_fun_id,1) AS form_desc
        FROM APPL_BUS_FUN WHERE APBUF_PAR_FUN_ID ='SUP_DET_TRANS' AND 
APBUF_FUN_ID IN ('SUP1030','SUP1040','SUP1080','SUP1010','SUP1120','SUP1130','SUP1180','SUP1160')
Which gives the following result
Rate Contract Details 
NCR
Supplier Document Details 
Stocks
Purchase Order
Purchase Reciept
Supplier Aging Details
Supplier Balance
I need to organize the output as
Supplier Balance
Supplier Document Details 
Supplier Aging Details
Stocks
Purchase Order
Purchase Reciept
NCR
Rate Contract details
Could someone help me pls!

Wilhelm wundt wrote:
There is no specific connection I coded directly hard value, but I'm getting output like

Supplier Balance
Supplier Aging Details
Stocks
Purchase Order
Purchase Reciept
NCR
Rate Contract details
Supplier Document Details   //It must be second one But it resides last

I had used this query

select form_desc
from(
select func_find_busfun_desc('MEL', apbuf_fun_id,1) AS form_desc
FROM APPL_BUS_FUN
WHERE APBUF_PAR_FUN_ID ='SUP_DET_TRANS'
AND APBUF_FUN_ID IN ('SUP1030','SUP1040','SUP1080','SUP1010','SUP1120','SUP1130','SUP1180','SUP1160')
)
order by decode(form_desc,  'Supplier Balance',1,
'Supplier Document Details',2,
'Supplier Aging Details',3,
'Stocks',4,
'Purchase Order',5,
'Purchase Reciept',6,
'NCR',7,
'Rate Contract details',8,100)

Hope you got the code.
Decoding is a number of "form_desc" "based on your requirement. If the description given in the decoding is NOT EXACTLY matching your description the order is not correct. It seems that the description 'The Document provider Details' in your output and the decoding is slightly different (Extra space or typo...)

Tags: Database

Similar Questions

  • Need to get the result of the required format

    Hi all

    I'll have the data in a table below:

    IDNUM1num2
    1555555
    2123345
    3456567
    4666666

    IDNUM1num2
    1555555
    2123345
    3456567
    4666666

    and they need to get the result as below:. Help, please...

    IDNUM
    1555
    2123
    2345
    3456
    3567
    4666

    Thanks in advance...

    Hello

    So, instead of having 2 columns on 1 row, you want to have 1 column on 2 rows.  It's just that UNPIVOT:

    SELECT DISTINCT

    ID, num

    D

    UNPIVOT (num

    FOR the label IN (num1, num2)

    )

    ORDER BY id, num

    ;

    It is more effective than the UNION, because it requires only 1 pass through the table.

  • Need to get the result of joing the views dba

    Hello

    need to get the result of the fileds below in a database

    TABLE_NAME NOM_PARTITION NOM_TABLESPACE PARTITION_TYPE (RANGE?) PARTITION_RANGE_CONDITION SPACE_OCCUPIED_AS_OF_DATE (IN GB)

    can I know what are the points of view that I can use and application

    apprecaited for assistance

    Thank you

    Published by: user12266475 on November 2, 2011 11:33

    LONG data type is NOT friendly SQL.
    Consider the following:

    SQL> @long
    SQL> drop table test;
    
    Table dropped.
    
    SQL> create table test (id LONG);
    
    Table created.
    
    SQL> insert into test values(q'[RANGE     TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')]');
    
    1 row created.
    
    SQL> set serveroutput on
    SQL> DECLARE
      2  long_var LONG;
      3  var_var  VARCHAR2(2000);
      4  BEGIN
      5       dbms_output.enable(10000);
      6       SELECT id INTO long_var FROM test ;
      7       var_var := substr(long_var,19,19);
      8       dbms_output.put_line(var_var);
      9  END;
     10  /
    2009-01-01 00:00:00
    
    PL/SQL procedure successfully completed.
    
  • I need to return the result of a query on a stored procedure

    I need to return the result of a query to a stored procedure, I mean when I run a stored procedure it returns a result set in a select statement.
    Best regards...

    Hello.

    Do you really want a stored procedure for this?
    Why not just a script that contains the query?

    Assuming that you don't really want a stored procedure, you'll have to decide what to do with the results.
    An option is a slider.

    For example, you can write a procedure of this type to hold the query:

    CREATE OR REPLACE PROCEDURE USP_TEST
    (     out_cursor     OUT     SYS_REFCURSOR
    )
    IS
    BEGIN
         OPEN  out_cursor
         FOR     SELECT     *
              FROM     scott.emp;
    END  USP_TEST;
    /
    SHOW ERRORS
    

    You can move the cursor to another procedure for handling.

    You could test this in SQL * more by creating a variable blond:

    VARIABLE     usp_test_cursor     REFCURSOR;
    
    EXEC  usp_test (:usp_test_cursor);
    
    PRINT     :usp_test_cursor
    
  • Ask... How to reach the result sets in order?

    Let me give a few examples of data first to give an idea of what I am working with:

    Oracle: 10g
    --Table xTable
    
    NAME             DESC_ID
    ALAN                   2 
    AMY                    3
    BILL                    5
    BOB                     7
    CARL                   1
    CHRIS                  8
    DAN                    4
    DEREK                 6  
    So what I try to do is right out of names (ALAN, CHRIS, DAN) in ascending order (according to out of name) and then all the names (AMY, BILL, BOB, CARL, DEREK) in ascending order (according to out name)... and I want all of this in a single result set. So basically the first set of names in alphabetical order, followed by the rest of the names in alphabetical order.

    I want the output to look exactly like this:
    NAME       DESC_ID     
    ALAN               2
    CHRIS                8
    DAN                  4
    AMY                  3
    BILL                   5
    BOB                    7  
    CARL                  1
    DEREK                6  
    I tried the following, but it doesn't seem to work
    select distinct a.name, a.desc_id
    from xTable,
    (select distinct name, desc_id
    from xTable
    where DESC_ID  in (2,8,4)
    order by name
    ) type1,
    (select distinct name, desc_id
    from xTable
    where DESC_ID  in (1,3,5,6,7)
    order by name
    ) type2
    where desc_id in (type1, type2);
    The code above seems terribley unefficent and apparently not at the exit of the things in the order I want. Any ideas?

    Published by: user652714 on January 5, 2010 11:23

    Published by: user652714 on January 5, 2010 11:28

    If you have a known list of DESC_ID you could do something like this:

    SQL> WITH xTable AS
      2  (
      3          SELECT 'ALAN'   AS NAME, 1 AS TYPE_ID, 2 AS DESC_ID FROM DUAL UNION ALL
      4          SELECT 'AMY'    AS NAME, 2 AS TYPE_ID, 3 AS DESC_ID FROM DUAL UNION ALL
      5          SELECT 'BILL'   AS NAME, 2 AS TYPE_ID, 5 AS DESC_ID FROM DUAL UNION ALL
      6          SELECT 'BOB'    AS NAME, 2 AS TYPE_ID, 7 AS DESC_ID FROM DUAL UNION ALL
      7          SELECT 'CARL'   AS NAME, 2 AS TYPE_ID, 1 AS DESC_ID FROM DUAL UNION ALL
      8          SELECT 'CHRIS'  AS NAME, 1 AS TYPE_ID, 8 AS DESC_ID FROM DUAL UNION ALL
      9          SELECT 'DAN'    AS NAME, 1 AS TYPE_ID, 4 AS DESC_ID FROM DUAL UNION ALL
     10          SELECT 'DEREK'  AS NAME, 2 AS TYPE_ID, 6 AS DESC_ID FROM DUAL
     11  )
     12  SELECT  NAME
     13  ,       DESC_ID
     14  FROM    xTable
     15  ORDER BY
     16          (CASE
     17                  WHEN DESC_ID IN (2,8,4)         THEN 1
     18                  WHEN DESC_ID IN (1,3,5,6,7)     THEN 2
     19          END)
     20  ,       1
     21  /
    
    NAME               DESC_ID
    ----- --------------------
    ALAN                     2
    CHRIS                    8
    DAN                      4
    AMY                      3
    BILL                     5
    BOB                      7
    CARL                     1
    DEREK                    6
    
    8 rows selected.
    

    Another option would be to use the UNION, but he strikes the table twice instead of once as described above:

    SQL> WITH xTable AS
      2  (
      3          SELECT 'ALAN'   AS NAME, 1 AS TYPE_ID, 2 AS DESC_ID FROM DUAL UNION ALL
      4          SELECT 'AMY'    AS NAME, 2 AS TYPE_ID, 3 AS DESC_ID FROM DUAL UNION ALL
      5          SELECT 'BILL'   AS NAME, 2 AS TYPE_ID, 5 AS DESC_ID FROM DUAL UNION ALL
      6          SELECT 'BOB'    AS NAME, 2 AS TYPE_ID, 7 AS DESC_ID FROM DUAL UNION ALL
      7          SELECT 'CARL'   AS NAME, 2 AS TYPE_ID, 1 AS DESC_ID FROM DUAL UNION ALL
      8          SELECT 'CHRIS'  AS NAME, 1 AS TYPE_ID, 8 AS DESC_ID FROM DUAL UNION ALL
      9          SELECT 'DAN'    AS NAME, 1 AS TYPE_ID, 4 AS DESC_ID FROM DUAL UNION ALL
     10          SELECT 'DEREK'  AS NAME, 2 AS TYPE_ID, 6 AS DESC_ID FROM DUAL
     11  )
     12  SELECT  NAME
     13  ,       DESC_ID
     14  FROM
     15  (
     16          SELECT  NAME
     17          ,       DESC_ID
     18          ,       1 AS ORD_COL
     19          FROM    xTable
     20          WHERE   DESC_ID IN (2,8,4)
     21          UNION
     22          SELECT  NAME
     23          ,       DESC_ID
     24          ,       2 AS ORD_COL
     25          FROM    xTable
     26          WHERE   DESC_ID IN (1,3,5,6,7)
     27  )
     28  ORDER BY ORD_COL
     29  ,       NAME
     30  /
    
    NAME               DESC_ID
    ----- --------------------
    ALAN                     2
    CHRIS                    8
    DAN                      4
    AMY                      3
    BILL                     5
    BOB                      7
    CARL                     1
    DEREK                    6
    
    8 rows selected.
    
  • Need to print the results of a query in a CASE statement

    I want to print the results of a query in a CASE statement:

    SELECT RUN_STATUS

    Of

    (select check BOX WHEN COUNT (ROW_WID) = 0 THEN 'NO JOBS RAN AFTER' |) (select sysdate - XXAFL_MINUTES MINUTE)

    END RUN_STATUS

    of W_ETL_RUN_SDTL

    where START_TS >

    (sélectionnez sysdate-MINUTES de XXAFL_MINUTES)) where RUN_STATUS is not null; e

    The query above subtracted 5 minutes from SYSDATE and he shoots XXAFL_MINUTES. I am doing this because we could change the number of minutes in the future. I want to print the number of minutes in the case statement.

    If I execute this statement, it throws an error stating:

    ORA-00937: not a single group group function

    00937 00000 - 'not a single-group function.

    * Cause:

    * Action:

    Error on line: 1 column: 96

    How can I include "select sysdate - MINUTES of XXAFL_MINUTES" in the CASE that it calculates the number of minutes and it prints with the results.

    Thanks in advance!

    Hey guys,.

    I found the solution:

    SELECT

    RUN_STATUS | TO_CHAR ((sélectionnez sysdate-MINUTES de XXAFL_MINUTES), 'HH24:MI:SS')

    Of

    (select check BOX WHEN COUNT (ROW_WID) = 0

    THEN "NO JOB RAN.

    END RUN_STATUS

    of W_ETL_RUN_SDTL

    where

    START_TS > (select sysdate - XXAFL_MINUTES MINUTE))

    where

    RUN_STATUS is not null;

    The output:

    NO JOBS RAN AFTER 09:07:54

    Thanks to you all!

  • Need help understanding the results of security analysis.

    My agency has recently started using tool to fortify scanner of HP, which aims to analyze the code of the CF directly, rather than the rendered page.  The scanner always seems to mark our pages for some error when I use the following code (used to create a PDF file on the fly):

    <cfheader name="Content-Disposition" value="attachment;filename=#pdffile#">
    <cfcontent type="application/octet-stream" file="#expandPath('.')#\#pdffile#" deletefile="Yes">
    

    01. is line 299 in my code.

    I'm basically generates a name of file elsewhere on the page that is based on what a user is requested, then using the code above to create a downloadable PDF of this file.

    The error is:

    Manipulation of the header (validating input and representation, stream)

    The myfile.cfm file includes data not validated in a 299 online HTTP response header.  This allows attacks such as the poisoning of the cache, cross-site scripting, cross-user daub, hijacking the page, cookie or open redirect handling.

    I think it is one of two potential problems.

    1. ExpandPath() is exploitable
    2. The scanner is programmed to any variable passed to a Pavilion cfheader tag.

    Any thoughts?

    You need to scope the variable pdffile.  Without a specific scope, it could be overwritten by URL or form variables entrants.  I would try that and then re-run the analysis.

    HTH,

    -Dave

  • Need to execute the query twice in order to get results

    I have a query in which I need to run twice in a row to obtain results. The first round returns no value and each race after which returns lines expected.

    Any ideas?

    Champion wrote:
    I have a query in which I need to run twice in a row to obtain results. The first round returns no value and each race after which returns lines expected.

    Any ideas?

    Well, when I run a query through TOAD, SQL or SQL Developer *, it results the first time.

    So what you do differently? Or are we supposed to guess forever?

    {message: id = 9360002}

  • Need to query the result with two different of a same attribute values

    Hi all

    I have a search query where I need the query result when an attribute have two different values (e.g.: want the query result when the attribute 'status' is equal to 1 and 2)

    And also, the user will be able to search by any State result.

    What is the best way to implement this.

    Thank you
    DK

    The solution to this use case is to put the part by default ((statut == 1 ou statut == 2) and: bindUserInput is null) as part of the query and the Pratt of the query to run when a value is entered by the user in a view criteria. East view criteria (Status ==: bindUserInput) and the value of the checkbox to ignore the values null. If the binding variable: bindUserInput is null, only the portion of the query is running, if the binding variable is not null, the display criteria is added at the request of three and three default components will not return any line.

    Timo

  • Need help on the results of a bizarre query...

    Hi guys,.

    I need your help

    Requirement is:-suppose we have under titles in a single table;

    HULK
    THE INCREDIBLE HULK - 2001 (DO NOT USE)
    INVERSE OF HULK
    INCREDIBLE HULK U/A
    BRING ME THE HEAD OF THE INCREDIBLE HULK
    JENNIFER JASON LEIGH, HULK HOGAN
    HULK 2
    BRIDE OF THE INCREDIBLE HULK
    HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD
    THE INCREDIBLE HULK #03 (1979/80)
    HULK HOGAN CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)


    Now, he must: -.

    O/p should be below order without duplicate records

    HULK first, then

    HULK then %

    HULK %.


    O/p: -.


    HULK
    HULK 2
    HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD
    HULK HOGAN CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)
    THE INCREDIBLE HULK - 2001 (DO NOT USE)
    INVERSE OF HULK
    INCREDIBLE HULK U/A
    BRING ME THE HEAD OF THE INCREDIBLE HULK
    JENNIFER JASON LEIGH, HULK HOGAN
    BRIDE OF THE INCREDIBLE HULK
    THE INCREDIBLE HULK #03 (1979/80)


    How can do us using sql query? Is it possible to make a request?
    Or to do table PL/SQL etc.?

    There should be no duplicates if you use more than a query or a single query.
    Can you help me?

    tappusingh wrote:

    O/p should be below order without duplicate records

    HULK first, then

    HULK then %

    HULK %.

    Maybe something like:

    SQL> WITH test_tab
      2         AS (SELECT   'HULK' col FROM DUAL
      3             UNION ALL
      4             SELECT   'THE INCREDIBLE HULK - 2001 (DO NOT USE)' FROM DUAL
      5             UNION ALL
      6             SELECT   'REVERSE HULK' FROM DUAL
      7             UNION ALL
      8             SELECT   'INCREDIBLE HULK U/A' FROM DUAL
      9             UNION ALL
     10             SELECT   'BRING ME HEAD OF THE HULK' FROM DUAL
     11             UNION ALL
     12             SELECT   'JENNIFER JASON LEIGH, HULK HOGAN' FROM DUAL
     13             UNION ALL
     14             SELECT   'HULK 2' FROM DUAL
     15             UNION ALL
     16             SELECT   'BRIDE OF THE INCREDIBLE HULK' FROM DUAL
     17             UNION ALL
     18             SELECT   'HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD' FROM DUAL
     19             UNION ALL
     20             SELECT   'INCREDIBLE HULK #03 (1979/80)' FROM DUAL
     21             UNION ALL
     22             SELECT   'HULK HOGAN''S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)'
     23               FROM   DUAL)
     24    -- " end of test data "
     25    SELECT   DISTINCT col
     26      FROM   test_tab
     27  ORDER BY   CASE
     28                WHEN col = 'HULK' THEN 1
     29                WHEN col LIKE 'HULK%' THEN 2
     30                WHEN col LIKE '%HULK%' THEN 3
     31                ELSE 4
     32             END, col
     33  /
    
    COL
    -----------------------------------------------------------
    HULK
    HULK 2
    HULK HOGAN'S CELEBRITY CHAMPIONSHIP WRESTLING #01 (2008/09)
    HULK HOGAN, DAVID WILLEY, NATASHA BEDINGFIELD
    BRIDE OF THE INCREDIBLE HULK
    BRING ME HEAD OF THE HULK
    INCREDIBLE HULK #03 (1979/80)
    INCREDIBLE HULK U/A
    JENNIFER JASON LEIGH, HULK HOGAN
    REVERSE HULK
    THE INCREDIBLE HULK - 2001 (DO NOT USE)
    
    11 rows selected.
    
    SQL>
    

    Kind regards
    JO

  • need to get the result of vertically

    Hello

    declare
    string_to_parse varchar2 (2000): = 'abcdefg, hiklmnopqrst;
    l_count number;
    l_value varchar2 (2000);
    Start
    string_to_parse: = string_to_parse | «, » ;
    l_count: = length (string_to_parse) - length (replace (string_to_parse, ',', "));
    -In oracle 11g, use regexp_count to determine l_count
    because me in 1... l_count loop
    Select regexp_substr(string_to_parse,'[^,]+',1,i) in the double l_value;
    dbms_output.put_line (l_value);
    end loop;
    end;


    If I run this I get years like
    ABCDEFG
    hiklmnopqrst

    but I need the answer as
    one
    b
    c

    could someone help me to get like this

    I think that's what you want:

    WITH t AS
    (SELECT 'abcdefg,hiklmnopqrst' string_to_parse FROM dual)
    SELECT SUBSTR(REPLACE(string_to_parse, ','), level, 1)
    FROM   t
    CONNECT BY level <= LENGTH(REPLACE(string_to_parse, ','))
    
  • Pavilion Elite HPE-170 t: need help with the result of a command prompt to Power Options

    I have recently upgraded to Windows 10 in Windows 7.  Like so many thousands of people, I problelms of sleep mode.  Mine will not be auto-sleep.  It has been suggested that I saw to run command prompt: powercfg-applications

    It supposedly will list the items running on your computer which can now be auto-sleep to work.  I tried several times and up to now, I get the same item displayed each time.  This is what is displayed: \device\harddiskvolume2\windows\sysWOW64\svchost.exe (hpqddsvc) is followed by this message: a file delete operation is underway

    My first thought is that if there is an operation to remove file in progress all the time, it's maybe the reason why my computer is not auto-sleep.  If there is someone out there who can shed some light on this situation, I would appreciate the help.

    EUREKA * SOLVED

    I found the answer to my problem!  After using the control system: powercfg-query and get the answer: \device\harddiskvolume2\windows\sysWOW64\svchost.exe (hpqddsvc) delete file operation is in progress

    I started looking for whatever it is associated with the answer above.  In the Manager of tasks in respect of the services, I found the name of the file hpqddsvc, with a description of HP CUE DeviceDiscovery Service was running.  When I stopped the task and re-tried in opt power standby mode, it worked correctly.  In the Configuration of the system (by typing msconfig at the run prompt) on the Services tab, I unchecked the box for HP CUE DeviceDiscovery Service and rebooted the computer.  The service is no longer running.

    I'm sure that this Service has been added to my computer when I downloaded the hp.com/support product detection tool .  The tool scans your computer to detect and identify HP products.

    This can be useful to others who have the problem of the auto-sleep I've had.

  • How to display the results of the database from several tables in descending order?

    I have a key word to search for images on my website that allows visitors to search for specific things. My db msysql has 15 tables and for the search function I use a UNION ALL operation to join them any visitor can find all tables at the same time. The problem is that all the results are in ascending order. How can I get the results in descending order.

    SELECT *.

    FROM table1

    Keyword WHERE AS id LIKE %s or %s

    UNION ALL

    SELECT *.

    FROM table2

    Keyword WHERE AS id LIKE %s or %s

    UNION ALL

    SELECT *.

    TABLE 3

    Keyword WHERE AS id LIKE %s or %s

    PS

    I tried this and it doesn't work:

    SELECT * FROM table1 WHERE AS %s or id AS %s ORDER BY id DESC keyword

    and I know that this is not conventional to use SELECT * with so many tables, but believe me, I have my reasons. I'm not trying to do is to wrap the whole UNION within an external SELECTION

    Once more, the order by clause can only appear at the end of the last select statement in a UNION query. You have it on all select statements.

  • How to display the results in the order based on the value of research

    Hi all

    How to display the results in the slot order.
     
    
    CREATE TABLE TEST( SONGID  NUMBER, TITLE   VARCHAR2(200))
    
    INSERT INTO TEST(SONGID,TITLE) VALUES (10,'AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (11,'CICCONE, MADONNA (CA)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (12,'DALLIN, MADONNA LOUISE/STOCK');
    INSERT INTO TEST(SONGID,TITLE) VALUES (13,'MADONNA');
    INSERT INTO TEST(SONGID,TITLE) VALUES (14,'MADONNA (A)/ AHMADZAI, MIRWAIS (C)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (15,'MADONNA (CA)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (16,'MIRWAIS AHMADZAI, MADONNA');     
    INSERT INTO TEST(SONGID,TITLE) VALUES (17,'MIRWAIS (CA)/ MADONNA (CA),AHMADZAI');
    INSERT INTO TEST(SONGID,TITLE) VALUES (18,'MADONNA (CA),CICCONE');
    
    SELECT *FROM  TEST WHERE INSTR (TITLE, 'MADONNA') > 0
    
    output: 
    SONGID     TITLE
    10     AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)
    11     CICCONE, MADONNA (CA)
    12     DALLIN, MADONNA LOUISE/STOCK
    13     MADONNA
    14     MADONNA (A)/ AHMADZAI, MIRWAIS (C)
    15     MADONNA (CA)
    16     MIRWAIS AHMADZAI, MADONNA
    17     MIRWAIS (CA)/ MADONNA (CA),AHMADZAI
    18     MADONNA (CA),CICCONE
    
    Expected output :
    13     MADONNA
    14     MADONNA (A)/ AHMADZAI, MIRWAIS (C)
    15     MADONNA (CA)
    18     MADONNA (CA),CICCONE
    ..
    ..
    ..
    ..
    ...
    If the user makes a search with "MADONNA", I view the results as title begins with "MADONNA" first then the rest of the records.
    Please let me know is possible to show the results in this order.


    Kind regards
    Rajasekhar

    This can be a little more specific:

    SQL> SELECT *
      2  FROM   TEST
      3  WHERE  INSTR (TITLE, 'MADONNA') > 0
      4  ORDER  BY INSTR (TITLE, 'MADONNA')
      5           ,TITLE
      6  ;
    
                  SONGID TITLE
    -------------------- --------------------------------------
                      13 MADONNA
                      14 MADONNA (A)/ AHMADZAI, MIRWAIS (C)
                      15 MADONNA (CA)
                      18 MADONNA (CA),CICCONE
                      12 DALLIN, MADONNA LOUISE/STOCK
                      11 CICCONE, MADONNA (CA)
                      17 MIRWAIS (CA)/ MADONNA (CA),AHMADZAI
                      16 MIRWAIS AHMADZAI, MADONNA
                      10 AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)
    
  • Procedure to export the result of the query to an excel or csv

    Hi all

    I have two identical paintings

    EMP_TEST OF THE EMP

    ID ID NAME

    1     SAM                      1        SAM

    2 JOHN 2 ROCK

    3 3 STEVE BRAND

    I need to combine the result under the query and intent to export data to excel using a procedure

    my query is

    Select 'EMP_ID', E1. EMP_ID, AND. EMP_ID from emp E1,

    emp_test AND WHERE E1. EMP_ID = AND. EMP_ID

    UNION

    Select "EMP_NAME", E1. EMP_NAME, AND. Emp E1 EMP_NAME,

    emp_test AND WHERE E1. EMP_ID = AND. EMP_ID

    but I get this error message

    ORA-01790: expression must have same type of corresponding data

    EMP_ID is a number and EMP_NAME is of type varchar.

    I need any idea or suggestion on sub queries.

    (1) I have to combine the result set in a single query.

    (2) I need to write the procedure that will export the result of the query to an excel or csv.

    Thank you.

    As PR has said, there are ways that have already been explained in this forum to write in external files. For your query condition, try this.

    SELECT CASE WHEN (REGEXP_LIKE (T1.ID,'[^ [: alpha:]] "")) THEN 'EMP_ID '.

    ELSE "EMP_NAME' END AS COL_NAME.

    T1.ID,

    T2.ID

    DE)

    SELECT CASE WHEN ID IS NULL THEN NAME ANOTHER TO_CHAR (ID) END AS ID,

    ROW_NUMBER () OVER(ORDER BY RN NULLS FIRST,ID) RN

    DE)

    SELECT ID, NULL,

    NAME,

    RN ID

    FROM EMP

    UNION ALL

    SELECT ID,

    NAME,

    RN NULL

    FROM EMP)) T1.

    (SELECT CASE WHEN ID IS NULL THEN NAME ANOTHER TO_CHAR (ID) END AS ID,)

    ROW_NUMBER () OVER(ORDER BY RN NULLS FIRST,ID) RN

    DE)

    SELECT ID, NULL,

    NAME,

    RN ID

    OF EMP_TEST

    UNION ALL

    SELECT ID,

    NAME,

    RN NULL

    OF EMP_TEST)) T2

    WHERE T1. RN = T2. RN;

    OUTPUT:

    COLUMN-NAME ID ID
    --------  ---------------
    1 1 EMP_ID
    2 2 EMP_ID
    3 3 EMP_ID
    SAM EMP_NAME MARK
    EMP_NAME JOHN JOHN
    EMP_NAME STEVE DARREN

    6 selected lines.

Maybe you are looking for

  • Question mark flashing at startup

    Spring 2011 MBP with EL Capitan.  Thus, used my MBP last night and he started beachballing and force apps to quit smoking, I started but performance has not improved and the beachballing continued.  Was not yet able to click on the Apple icon to rest

  • USB-6501 as Stepper Motor Driver

    Hello I've been away from LabVIEW for awhile (6 years or more) and I have a small task to achieve and am really struggling to start. I have a USB-6501 DIO and Labview version 8.6.  I need to drive a motor not not that requires 4 input (in my case 2 P

  • Problem with connection yahoo on vista

    I need help with yahoo on vista. Since I installed SP2 I can't sign in yahoo. I've already deleted yahoo and deleted the registry, after rebooting, I downloaded a new yahoo yahoo.com and same problem. Below that you can results I got from yahoo. Chec

  • Install Itunes 10.0 on 64 bit Vista machine

    Whenever I tried to install Itunes 9.0 or higher on my HP Vista 64 bit computer, I get the error now. 0 Also useful vote The error reads as follows: An error occurred during the installation of Assembly' Microsoft.VC80.CRT, version = "8.0.50727.4053"

  • 3050 J611a has stopped free wireless

    I got my printer put in place and works wirelessly for several months, then all of a sudden it stopped - I don't think that something has changed on my network, it seems to be the printer. I tried to re-login via WPS, but the reports WPS printer erro