Need to query to fetch the father & grandfather name?

Dear all,

I am using the suite of table to fetch the name & Last_Name, but not able to find information for the name of the father and grandfather.

per_all_people_f

What table with father & grandfather information fields?

Thank you
M K

Select
PAPF.first_name, papf.per_information1 father_name,
PAPF.per_information2 grandfather_name, papf.last_name family_name
the women's wear per_all_people_f

for Arab names, at least in Saudi legislation you can use this function:

/ * get the name of the employee in Arabic * /.
FUNCTION decode_arabic_name)
p_person_id number,
p_effective_date date default sysdate
) return varchar2
is
v_arabic_name varchar2 (5000);
Start
Select
(decode ((nvl(paf.per_information3,'') |))) '),' ', ", paf.per_information3 | ' ')
|| Decode ((NVL(PAF.per_information4,'') |)) '),' ', ", paf.per_information4 | ' ')
|| Decode ((NVL(PAF.per_information5,'') |)) '),' ', ", paf.per_information5 | ' ')
|| Decode ((NVL(PAF.per_information6,'') |)) '),' ', ", paf.per_information6 | ' '))
in v_arabic_name
of paf per_all_people_f
where paf.person_id = p_person_id
and p_effective_date between paf.effective_start_date and paf.effective_end_date;
Return v_arabic_name;
exception
When no_data_found then
return ";
while others then
return ";
end decode_arabic_name;

Tags: Oracle Applications

Similar Questions

  • Need help query view with the 'Level' column name

    Hello world

    I use Oracle DB 10 g

    I have this request
    SELECT  count(per_id) 
    FROM    XXITS_EMP_MSTR_V
    WHERE   per_id = 213214 
    AND     Level='Technical Staff / Officer'
    XXITS_EMP_MSTR_V is a view created by someone else.

    I get the error "ORA-01788: CONNECT BY clause in this query block" for the the above statement.
    Is it possible that I can always get the result without changing the view?

    Any help is appreciated...

    Thank you
    Elmer

    Elmer says:
    Hello world

    I use Oracle DB 10 g

    I have this request

    SELECT  count(per_id)
    FROM    XXITS_EMP_MSTR_V
    WHERE   per_id = 213214
    AND     Level='Technical Staff / Officer'
    

    Place the level with quotes

    AND "Level" = 'Technical Staff / Officer'
    

    Make sure that the case is used correctly when using double quotes.

  • I need a query that selects the amount of records for each day of a table.

    I need a query that selects the amount of records for each day of a table.
    For example, the result would be:

    1 14 date
    Date 2-3

    etc.

    Any ideas?

    Sort:

    SELECT count ([IDCommentaire]), convert (varchar, dateAdded, 112)

    OF COMMENTSgroup by convert (varchar, dateAdded, 112)

  • I need a query that returns the average amount of characters from text colum in MS SQL.

    I need a query that returns the average amount of characters from text colum in MS SQL.

    Could someone show me how?

    Sorting, I need of the

    DATALENGTH

    function

  • Need a query to return the first and last date for a rowset.

    Hello

    I have a query which can be simplified to the following data, if
    Assume that it is my dataset, with THE_VALUE of
    Sign (Anum) therefore,-1, 0 or 1.

    * (Sorry for crushed registration. "I can't understand this website's rich text formatting.) *

    THE_VALUE THE_DATE THE_MEMBER
    1 0 1 January 2007
    1 0 1 February 2007
    1 0 1 March 2007
    1. 1 April 1, 2007
    1 1 1 May 2007
    1 0 1 June 2007
    1. 1 July 1, 2007
    1. 1 August 1, 2007
    1 0 01 - sep - 2007
    2 0 1 January 2007
    2 1 February 1, 2007
    2 0 1 March 2007
    2. 1 April 1, 2007
    2 1 1 May 2007
    2 0 1 June 2007
    -2 1 1 July 2007
    2. 1 August 1, 2007
    2. 1 01-sep-2007
    3 0 1 January 2007
    3. 1 February 1, 2007
    3 0 1 March 2007
    3 0 1 April 2007
    3. 1 May 1, 2007
    3 0 1 June 2007
    3. 1 July 1, 2007
    3. 1 August 1, 2007
    3 0 01 - sep - 2007

    I need to get the lines with the THE_MEMBER, the values of the first and the last
    THE_DATE, where the value is - 1, and the date range is the last
    set of lines to the Member, with the same value of THE_VALUE.

    I tried the following to get the dates of first and last for a set
    consecutive months with the same value for the Member.

    SELECT the_member
    the_value
    the_date
    first_value (the_date)
    in the first_date (PARTITION the_member, ORDER BY the_member the_value, the_date)
    last_value (the_date)
    during the last_date (PARTITION the_member, ORDER BY the_member the_value, the_date)
    OF togola
    ORDER BY the_member
    the_date;

    At first, it seems to work, but then, when the return value
    an old value, FIRST_DATE will be the first of all the lines containing
    This value for the Member rather than the first of consecutive
    rows with this value for the Member. Apparently the partitioning
    occurs before the order.

    THE_MEMBER THE_VALUE THE_DATE FIRST DATE LAST DATE
    1 0 January 1, 2007 January 1, 2007 January 1, 2007
    1 0 1 February 2007 1 January 2007 1 February 2007
    1 0 1 March 2007 1 January 2007 March 1, 2007
    1. 1 April 1, 2007 April 1, 2007 April 1, 2007
    1. 1 May 1, 2007 April 1, 2007 may 1, 2007
    1-0 June 1, 2007 January 1, 2007 June 1, 2007
    1. 1 July 1, 2007 April 1, 2007 July 1, 2007
    1. 1 August 1, 2007 April 1, 2007 August 1, 2007
    1 0 01 - sep - 2007 1 January 2007 01-Sep-2007

    2 0 January 1, 2007 January 1, 2007 January 1, 2007
    2 1 1 February 2007 February 1, 2007 February 1, 2007
    2 0 1 March 2007 1 January 2007 March 1, 2007
    2. 1 April 1, 2007 February 1, 2007 April 1, 2007
    2 1 1 May 2007 February 1, 2007 may 1, 2007
    2-0 June 1, 2007 January 1, 2007 June 1, 2007
    -2 1 1 July 2007 February 1, 2007 July 1, 2007
    2. 1 August 1, 2007 February 1, 2007 August 1, 2007
    2. 1 01-sep-2007 1 February 2007 01-Sep-2007

    3 0 January 1, 2007 January 1, 2007 January 1, 2007
    3. 1 February 1, 2007 February 1, 2007 February 1, 2007
    3 0 1 March 2007 1 January 2007 March 1, 2007
    3 0 April 1, 2007 January 1, 2007 April 1, 2007
    3. 1 May 1, 2007 February 1, 2007 may 1, 2007
    3 0 June 1, 2007 January 1, 2007 June 1, 2007
    3. 1 July 1, 2007 February 1, 2007 July 1, 2007
    3. 1 August 1, 2007 February 1, 2007 August 1, 2007
    3 0 01 - sep - 2007 1 January 2007 01-Sep-2007

    That's what I need to get in the end.

    THE_MEMBER FIRST DAY DATE OF LAST
    July 2 1 2007-01 - Sep - 2007

    Any ideas would be really appreciated.

    Published by: user10700981 on December 17, 2008 13:57

    Hello

    We'll call the lines whose the_value =-1 'good' lines and lines with the_value! =-1 ranks of 'bad '.

    For each value of the_value, we need the first and last values of the_date where
    the last row in the group is good
    (b) the current line is good
    (c) there is a lot of lines from the current line to the end of the Group
    Condition (a) is just a special case of (c).
    Conditions (b) and (c) are similar: (b) if applied to the current line, (c) applies to all lines after him. They can easily be combined into a single test that counts the number of lines after the current line or bad.

    Which produces the results you requested of the sample data that you provided:

    WITH     count_bad     AS
    (
         SELECT     the_member
         ,     the_date
         ,     COUNT     ( CASE
                        WHEN  the_value != -1 -- assuming the_value is never NULL
                        THEN  1
                     END
                   ) OVER     ( PARTITION BY     the_member
                          ORDER BY     the_date     DESC
                        )     AS bad_cnt
         FROM     table_x
    )
    SELECT     the_member
    ,     MIN (the_date)     AS first_date
    ,     MAX (the_date)     AS last_date
    FROM     count_bad
    WHERE     bad_cnt     = 0
    GROUP BY     the_member
    ORDER BY     the_member;
    
  • Need to query to get the Menu - to submenu and functions attached to a responsibility

    Hello

    I have this same need, but a higher level: application Menu, submenu, function, responsibility,


    I appreciate any pointers people gave many discussions, but so far I have not found one that led to an answer.

    Here's what I have implemented so far. I still need help with it.

    Yes, I am new, any help is appreciated, thanks,
    C


    -MATRIX of RESPONSIBILITIES version 7
    -need to check: these are all assets / Exclusions are excluded, if functions can be added?

    SELECT DISTINCT fr.application_id "App ID",
    "App name", fat.application_name
    FRT.responsibility_name,
    f.menu_id,
    f.user_menu_name "main Menu."
    FME.entry_sequence "Seq"
    fMet.prompt "guest."
    -"Function."
    F2.user_menu_name "submenu."
    FME2.entry_sequence "Seq Sub."
    fmet2.prompt 'Sub Menu fast. "
    -"Submenu function."
    fmet2. Description "Sub description."
    FME2.grant_flag,
    ffft.function_id,
    ffft.user_function_name "Function_Description"
    DECODE (fme.sub_menu_id, NULL,
    "FUNCTION."
    DECODE (fme.function_id, NULL, "BOTH", "Submenu")
    ) TYPE-needs work

    FROM fat apps.fnd_application_tl.
    Apps.fnd_user fu,
    Apps.fnd_user_resp_groups urg,
    Apps.fnd_responsibility en,
    Apps.fnd_responsibility_tl frt,
    Apps.fnd_form_functions_tl ffft,

    Apps.fnd_menus_vl f,
    Apps.fnd_menus fm,
    Apps.fnd_menu_entries fme,
    Apps.fnd_menu_entries_tl fmet,

    Apps.fnd_menus_vl f2,-note recursive table calls for the submenu record
    Apps.fnd_menus fm2,
    Apps.fnd_menu_entries wwf2,
    Apps.fnd_menu_entries_tl fmet2

    -the joints and the standard selection criteria
    WHERE 1 = 1
    AND fme.function_id = ffft.function_id (+)

    AND fu.user_id = urg.user_id
    AND urg.responsibility_id = fr.responsibility_id
    AND urg.responsibility_application_id = fr.application_id
    AND fr.application_id = fat.application_id
    AND fr.responsibility_id = frt.responsibility_id
    AND fr.application_id = frt.application_id

    AND f.menu_id = fr.menu_id
    AND fr.menu_id = fm.menu_id
    AND fm.menu_id = fme.menu_id
    AND fme.menu_id = fmet.menu_id
    AND fme.entry_sequence = fmet.entry_sequence

    call - recursive for get info menu SUP
    AND f2.menu_id = fm2.menu_id
    AND fm2.menu_id = fme.sub_menu_id
    AND fm2.menu_id = fme2.menu_id
    AND fme2.menu_id = fmet2.menu_id
    AND fme2.entry_sequence = fmet2.entry_sequence

    AND fmet.language = 'en '.
    AND fmet2.language = 'en '.

    -ESTABLISH CRITERIA SPECIFIC HERE
    AND IN fr.application_id (8401, 140)-id App 8401 = PSB 140 = active
    - AND fr.application_id = 140 and frt.responsibility_name = 'Active Fixed survey'
    - AND f.user_menu_name = 'FA_MAIN. '
    - AND fmt2.user_menu_name = "PSB_NAVIGATE_SUPERUSER" Add fnd_menus_tl

    ORDER BY 1,2,3,4,5,6,7,8,9,10,11;

    OK, this meets our audit requirements.

    It shows what is current and has the right-hand columns showing what is finished or excluded.

    -The matrix of the request, responsibility, Menu, guest, function, SubFunction, submenu
    -which indicates the date of end of resposibility and exclusions

    Select second.application_id "App ID"
    , second.application_name "App name".
    second.responsibility_id "RESP ID"
    , second.responsibility_name 'responsibility '.
    second.menu_id "Menu ID"
    second.user_menu_name 'Name of main Menu'
    , second.entry_sequence "Seq".
    , second.prompt 'guest '.
    , second.function_id "function ID".
    , second.user_function_name 'function '.
    second.func_descrip 'Function description'
    , second.sub_menu_id 'the submenu ID.
    , second.sub_menu_name 'the submenu name.
    second.sub_seq "Sub Seq"
    , second.sub_prompt 'SubPrompt '.
    , second.sub_func_id 'ID SubFunction.
    , second.sub_func "sub-function.
    second.sub_func_descrip "Business line description"
    , second.sub_sub_menu_id 'Sub-sous-menu ID ".
    second.grant_flag "Grant Flag"
    , second.resp_end_date "RESP-End Date.
    , decode (exc.rule_type, 'F', (select "Ex F:' |")) exc.action_id
    of fnc fnd_form_functions_vl
    where fnc.function_id = exc.action_id
    and second.function_id = exc.action_id
    )
    ) Excluded_Function
    , decode (exc.rule_type, 'F', (select "SF Ex: ' |")) exc.action_id
    of fnc fnd_form_functions_vl
    where fnc.function_id = exc.action_id
    and second.sub_func_id = exc.action_id
    )
    ) Excluded_Sub_Function
    , decode (exc.rule_type, I ', (select "Ex M:' |")) exc.action_id
    of fnc fnd_form_functions_vl
    where fnc.function_id = exc.action_id
    and second.menu_id = exc.action_id
    )
    ) Excluded_Menu
    , decode (exc.rule_type, I ', (select "Ex SM:" | ")) exc.action_id
    of fnc fnd_form_functions_vl
    where fnc.function_id = exc.action_id
    and second.sub_menu_id = exc.action_id
    )
    ) Excluded_Sub_Menu
    , decode (exc.rule_type, I ', (select "Ex SSM: ' |")) exc.action_id
    of fnc fnd_form_functions_vl
    where fnc.function_id = exc.action_id
    and second.sub_sub_menu_id = exc.action_id
    )
    ) Excluded_Sub_Sub_Menu

    Of
    (select first.application_id
    first.application_name
    first.responsibility_id
    first.responsibility_name
    first.end_date as resp_end_date
    first.menu_id
    first.user_menu_name
    first.entry_sequence
    first.prompt
    first.function_id
    ffft.user_function_name
    ffft.description as func_descrip
    first.sub_menu_id
    fmv2.user_menu_name as sub_menu_name
    fme2.entry_sequence as sub_seq
    fmet2.prompt as sub_prompt
    fme2.function_id as sub_func_id
    ffft2.user_function_name as sub_func
    ffft2.description as sub_func_descrip
    fme2.sub_menu_id as sub_sub_menu_id
    first.grant_flag

    Of
    (
    Select fat.application_id
    fat.application_name
    fr.responsibility_id
    frt.responsibility_name
    fr.end_date
    fr.menu_id
    fmv.user_menu_name
    fme.entry_sequence
    fmet.prompt
    fme.sub_menu_id
    fme.function_id
    fme.grant_flag
                        
    fat apps.fnd_application_tl
    apps.fnd_responsibility en
    apps.fnd_menus_vl JVM
    apps.fnd_responsibility_tl frt
    apps.fnd_menu_entries fme
    apps.fnd_menu_entries_tl fmet

    -the joints and constant selection
    where fat.application_id = fr.application_id (+)
    and fr.menu_id = fmv.menu_id (+)
    and fr.responsibility_id = frt.responsibility_id (+)
    and fr.menu_id = fme.menu_id (+)
    and fme.menu_id = fmet.menu_id (+)
    and fme.entry_sequence = fmet.entry_sequence (+)
    and fmet.language = 'en '.

    --------------------------------------
    -Add the specific selection criteria-
    --------------------------------------
    - and fat.application_id = 8401 - for DEVL 19080 lines
    - and fr.responsibility_id = 51856
    fat.application_id = & AppID

    order by 1,2,3,4,5,6,7,8,9,10,11,12

    ) firstly - for info in the main menu, the responsibility and the application
             
    apps.fnd_menus_vl fmv2 - for the submenu record
    apps.fnd_menu_entries wwf2
    apps.fnd_menu_entries_tl fmet2

    apps.fnd_form_functions_tl ffft - for service info
    apps.fnd_form_functions_tl ffft2 - FYI SubFunction
               
    -left outer joins keep of the original disks and add any information menu and void function
    where first.function_id = ffft.function_id (+)
    and first.sub_menu_id = fmv2.menu_id (+)
    and first.sub_menu_id = fme2.menu_id (+)
    and fme2.menu_id = fmet2.menu_id (+)
    and fme2.entry_sequence = fmet2.entry_sequence (+)
    and fme2.function_id = ffft2.function_id (+)

    order of 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21

    ) second - adds Info menu and void function

    Join external apps.fnd_resp_functions exc - of exclusions to the left
    on (second.application_id = exc.application_id
    and second.responsibility_id = exc.responsibility_id
    and (second.function_id = exc.action_id
    or second.sub_func_id = exc.action_id
    or second.menu_id = exc.action_id
    or second.sub_menu_id = exc.action_id
    or second.sub_sub_menu_id = exc.action_id
    )
    )

    order of 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21;

  • need to query to find the rows

    Hello

    I need to request to see for a perticular line table parent, that references the number of rows in the tables of children, and child to child tables. in herirachy mode.

    If anyone knows it please help me

    I assumed that it would be difficult to achieve a generic script to get the answer that can help in all situations... you see table definitions in your diagram and try... as in the case of the table emp and dept.

    Select * from Department where deptno in
    (select deptno, count (*) in Group emp by deptno having count (*) > 1)

    (this gives rows of table dept where, for corresponding deptno there are several rows in the emp table).

    Thank you
    Cedric

  • I need sql query to discover the 5 last update on the back-end oracle

    Hi all

    I have payable obligation under Oracle, I want to know the last 5 updated to the oracle of in the back end. the table of this 'AP_SYSTEM_PARAMETERS '.

    Please suggest me

    Kind regards

    Patel

    Hello

    There may be other ways, but for the time being to check this...

    Select *.

    from (select * from ap_system_parameters by last_update_date desc)

    where 1 = 1

    and rownum<>

  • SQL query to get the NULL records after the last matching flag

    I have a xx1 table with id and flag columns. So I want the data in this table, after the last flag matched. I want that data to id 7 in the rooms. Even if the id 2,3,5 are null flag 'Y' was at 6. ID so I need a query to get the data of the xx1 table after the last correspondence flag (from 7 to 9 id).

    SQL > create table xx1

    2 (identification number,

    3 flag varchar2 (10));

    Table created.

    SQL > insert into xx1 values (1, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (2, null);

    1 line of creation.

    SQL > insert into values xx1 (3, null);

    1 line of creation.

    SQL > insert into xx1 values (4, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (5, null);

    1 line of creation.

    SQL > insert into xx1 values (6, 'Y');

    1 line of creation.

    SQL > insert into values xx1 (7, null);

    1 line of creation.

    SQL > insert into values xx1 (8, null);

    1 line of creation.

    SQL > insert into values xx1 (9, null);

    1 line of creation.

    SQL > select * from xx1.

    FLAG OF THE ID

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

    1. IS

    2

    3

    4. IS

    5

    6. IS

    7

    8

    9

    9 selected lines.

    SQL >

    Hello

    user11164339 wrote:

    Hi Frank - when I run the query, I don't see the results data.

    I get

    FLAG OF THE ID

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

    7

    8

    9

    What you do differently?

  • Query to find the previous activity in STM

    I have a data base to reflect a State of Transition (STM) Machine. It contains 3 tables: activity, node, and Transition.

    Tables of knots and Transition are the configuration of the STM. They define the different possible States and the possible transitions between States.

    The way that I take through the STM is recorded in the activity Table. A record is created for each visited node.

    I need a query that uses the id of my current activity to find my previous activity, i.e. the activity that precedes me directly. The following rules apply:
    -My Id is meaningless
    -It should work for different configurations of the transition and the node tables, but:
    -The starting node is always the node "A".
    -There is no recursive transition, for example ('B', 'B');
    -There is no circular transitions, for example ('B', 'C') and ('C', 'B')
    -Transition and node tables will never change between the creation of the first activity and the execution of the query.
    -The path reflected in the activity table is always a valid path.
    -My current activity is always the last activity.

    For all data below, find the previous activity of activity with id = 4. The correct answer is "C".
    DROP TABLE Transition;
    DROP TABLE Activity;
    DROP TABLE Node;
    
    CREATE TABLE Node
    (
         Id VARCHAR2(1) PRIMARY KEY
    );
    
    CREATE TABLE Activity
    (
         Id Number(8,0) PRIMARY KEY,
         Node_Id VARCHAR2(1)
    );
    
    CREATE TABLE Transition
    (
         FromNode_Id VARCHAR2(1),
         ToNode_Id VARCHAR2(1)
    );
    
    ALTER TABLE Activity
    ADD FOREIGN KEY
    (Node_Id) REFERENCES Node(Id);
    
    ALTER TABLE Transition
    ADD FOREIGN KEY
    (FromNode_Id) REFERENCES Node(Id);
    
    ALTER TABLE Transition
    ADD FOREIGN KEY
    (ToNode_Id) REFERENCES Node(Id);
    
    INSERT INTO Node VALUES ('A');
    INSERT INTO Node VALUES ('B');
    INSERT INTO Node VALUES ('C');
    INSERT INTO Node VALUES ('D');
    
    INSERT INTO Transition VALUES ('A','B');
    INSERT INTO Transition VALUES ('B','C');
    INSERT INTO Transition VALUES ('B','D');
    INSERT INTO Transition VALUES ('C','D');
    
    INSERT INTO Activity VALUES (1,'A');
    INSERT INTO Activity VALUES (2,'B');
    INSERT INTO Activity VALUES (3,'C');
    INSERT INTO Activity VALUES (4,'D');
    Desired output:
    ID
    -
    C

    Hello

    Assuming that all Activity_id tells us nothing on the way, but all lines of activity together to form a single path, we can get results this way:

    WITH     all_paths    AS
    (
         SELECT     'A' || SYS_CONNECT_BY_PATH (a.Node_id, '/')
                  || '/'     AS node_id_path
         FROM     Transition  t
         JOIN     Activity    a  ON  a.Node_Id  = t.ToNode_Id
         WHERE     LEVEL             = (
                                SELECT  COUNT (*)
                             FROM     activity
                             ) - 1
         START WITH  t.FromNode_Id  = 'A'
         CONNECT BY  t.FromNode_Id  = PRIOR t.ToNode_Id
    )
    SELECT       REGEXP_SUBSTR ( node_id_path
                     , '([^/]+)/' || (
                                        SELECT  Node_Id
                                 FROM    activity
                                 WHERE   Id     = 4  -- target_id
                                    )
                             || '/'
                   , 1
                   , 1
                   , NULL
                   , 1
                   )     AS prev_id
    FROM       all_paths
    ;
    

    This means, there is some character (I used "/" above) that we know never appears in Activity.Node_Id.

    Since there are no loops in Transition, it cannot be more than 1 way that involves all activity lines. If there are N lines in operation, this full path will be one that extends to LEVEL = N - 1. (It is not N, N - 1, because the join between the activity and the Transition will always leave 1 line in activity with Node_Id = 'A'). As soon as we have the full path (which is node_id_path in 1 row, produced by all_paths), we just need to guess what was the Node_Id, which corresponds to the id of the target (4 in this example) and find the previous of the delimited node_id_path node_id.

  • Create a query to compare the values in the same table

    Suppose you have the table, below even ID occur for the same month as well as different months

    ID value of months
    --------------------------------------------------------------
    226220 201203 100
    1660 201204 200
    26739 201204 1010
    7750 201205 31.1

    I need a query to determine the results laid below

    The month ID value Prior_month_value Prior_Month
    ----------------------------------------------------------------------------
    1234 201203 10 201201 100
    3456 201206 56.1 201204 78


    Help, please

    Published by: Jaguar on 10 July 2012 03:00

    With the information we have, it's the best we can get to...

    SQL> with t as (select 226220 as ID, 201203 as Month, 100 as Value from dual union all
      2             select 1660, 201204, 200 from dual union all
      3             select 26739, 201204, 1010 from dual union all
      4             select 7750, 201205, 31.1 from dual)
      5  --
      6  -- end of example data
      7  --
      8  select decode(rownum,1,1234,3456) as id
      9        ,decode(rownum,1,201203,201206) as month
     10        ,decode(rownum,1,10,56.1) as prior_month_value
     11        ,decode(rownum,1,201201,201204) as prior_month
     12        ,decode(rownum,1,100,78) as value
     13  from (
     14        select * from t where rownum <= 2
     15       )
     16  /
    
            ID      MONTH PRIOR_MONTH_VALUE PRIOR_MONTH      VALUE
    ---------- ---------- ----------------- ----------- ----------
          1234     201203                10      201201        100
          3456     201206              56.1      201204         78
    

    Waste in... trash out.

  • Help needed dynamic query

    Hai I want dynamic query for framing
    CREATE TABLE PI4 (COR varchar2(1),dep varchar2(3),cod_rc varchar2(2))
    
    insert into pi4(dep,cod_rc) values('A01','5C')
    
    insert into pi4(dep,cod_rc) values('DAC','5L')
    HORN must be updated using dynamic query
    as below
    UPDATE PI4         
            SET
         PI4.COR = ’O’
    WHERE
         PI4.DEP IN ('A01','A02','A03')
    OR
         (
         PI4. dep IN ('DAC','FTS','G12')
         AND
         PI4.COD_RC = '5L'
         )
    sql_stament is that the variable must be set to above code.

    Pls help


    S

    Check below the code where the CO value is assigned dynamically to a p_cor variable

    DECLARE
    v_sql_statement VARCHAR2(32767) := NULL;
    p_cor VARCHAR2(10) := 'O';
    BEGIN
    v_sql_statement := 'UPDATE PI4 SET PI4.COR ='||p_cor||' WHERE (PI4.DEP IN (''A01'',''A02'',''A03'') OR (PI4. dep IN (''DAC'',''FTS'',''G12'') AND PI4.COD_RC = ''5L''))';
    EXECUTE IMMEDIATE v_sql_statement;
    END;
    

    If you do not need dynamic query to perform the update:

    See the code below:

    DECLARE
    p_cor VARCHAR2(10) := 'O';
    BEGIN
    UPDATE PI4 SET PI4.COR =p_cor WHERE PI4.DEP IN ('A01','A02','A03') OR (PI4. dep IN ('DAC','FTS','G12') AND PI4.COD_RC = '5L'));
    END;
    

    Published by: AP on July 27, 2010 03:39

    Published by: AP on July 27, 2010 04:51: end tag code included

  • Lower cost of query sql... but more time to fetch the records...

    Hello
    I have a 'strange' with a db view situation facing costly.
    I tried to reduce the cost of the overview
    specifically for 223 records fetched{the cost from 149 reduced to 74,
                                                           the recursive calls from 796 reduced to 224,
                                                           the consistent gets from 311516 reduced to 310341,
                                                            the physical reads from 7 reduced to 0}
    but the amount of time needed to fetch the results is greater than the old version of the db view....{it may be the double...}
    Have you any idea about this...????

    Note: I have got fresh statistics...
             I use db 10g v.2


    Thanks,
    Sim

    Try to trace the query and see what tkprofs shows you.
    ALTER session set events 10046 trace context name forever, level 12';
    Run the query
    "ALTER session set events ' trace 10046 name context off."

    Then, run tkprofs on the file path to see where the database devoted his time and effort. Do the same for the baseline query in a different session (so you will generate a different trace file).

    If that does not produce something useful, try to use
    "ALTER session set events ' trace 10053 name context forever."
    Run the query
    "ALTER session set events ' trace 10053 name context off."

    Then examine the trace file to see if you can learn anything.

    Given that you have given us something more to go, it's all the help I can give...

  • Hi I need query to find the details of the emp, when he get last hike

    Here is my table

    date treatment Eno

    10 10000 1 January 2014

    10 10000 February 1, 2014

    10 20000 1 - March - 2014

    10 20000 April 1, 2014

    20 20000 1 January 2014

    20 30000 February 1, 2014

    20 30000 1 - March - 2014

    20 30000 April 1, 2014

    30 40000 1 January 2014

    30 40000 February 1, 2014

    30 40000 1 - March - 2014

    30 50000 April 1, 2014

    I need a query for lower results

    10 20000 1 - March - 2014

    20 30000 February 1, 2014

    30 50000 April 1, 2014

    Thanks in advance

    Hi, Ravindra,

    1060739 wrote:

    Thank you, Roger.

    It worked for me

    Ravindra

    Don't forget to mark the thread as "answered".  It will help others with a similar problem, and it will save time to answer questions from people.

  • SQL query client fetch that has all the products

    Hi all

    I need a SQL query to retrieve the output as shown

    Table: ACCOUNT_SUMMARY

    prod_id Cust_id

    101 AAA

    BBB 101

    101. THE CCC

    102 AAA

    103 AAA

    102. THE CCC

    : Table

    Prod_id Prod_desc

    101 Home_loan

    Vehicle loan 102

    Loan education 103

    Expected results:

    Cust_id Prod_desc

    AAA Home_loan

    AAA auto loan

    Educational ready AAA

    Sorry, could not understand your question clearly.

    Do you want this:

    WITH account_summary
                      AS (SELECT 101 prod_id,'AAA' cust_id FROM dual UNION ALL
                          SELECT 101,'BBB' FROM dual UNION ALL
                          SELECT 101,'CCC' FROM dual UNION ALL
                          SELECT 102,'AAA' FROM dual UNION ALL
                          SELECT 103,'AAA' FROM dual UNION ALL
                          SELECT 102,'CCC' FROM dual)
        ,Product
              AS (SELECT 101 prod_id,'Home_loan' prod_desc FROM dual UNION ALL
                  SELECT 102,'Vehicle loan' FROM dual UNION ALL
                  SELECT 103,'Educational Loan' FROM dual
                  )
      , acc_count
          AS  (SELECT prod_id, cust_id ,count(*) OVER (PARTITION BY cust_id) cnt
                FROM account_summary
                )
    SELECT A.prod_id,P.prod_desc
    FROM acc_count A, product P
    WHERE A.prod_id = P.prod_id
    AND  cnt = (SELECT count(*) FROM product)
    ORDER BY A.prod_id
    

Maybe you are looking for

  • iPad Pro French keyboard issues

    Hello I hope I can find an answer here with your help, even if my problem may be specific to the configuration of the iOS keyboard 9 of the French. Whenever I press "4", AutoCorrect changes to a "4" "even if nothing of the sort is defined in the sett

  • my windows update are not displayed

    When I go to windows update, it comes back but can not see something his white... so now I can not turn on... or something... hope someone can help...

  • UM. MSI file

    When I turn on the computer, windows box install appears to install the Update Manager... but then asked for a drive to get all this.  where can I find this file...  UM. MSI

  • Windows Movie Makers is interrupted during playback in Vista 32 bit chronology

    Strange, it worked until a few weeks ago. Now when I add a video to the scenario and go there to play, he will play for about a minute and a half and then it stops but the clock continues to run. Then the screen goes all black.  I removed all the che

  • HI - A57 overexposed with external Flash HVL-56

    I bought the HVL-56 AM flash when I bought my original Alpha 100 camera and it served me well when I needed an external flash higher power.  When I updated the camera to the A57 - HI, I thought that the HVL-56 would work well since it uses the same s