Data in single row

thanks
Edited by: 786304 on May 25, 2011 12:22 PM

BluShadow .
I agree your opinion.
I resurrect it from google cache.
Hi All,
I have two queries as follows
Select
Xrc.Profile_Nbr Var_Profile_Nbr,
xsr.Profile_Nbr Var_Profile_Nbr,
Nvl(Ppa.First_Name,' ') Var_First_Name,
Nvl(Ppa.Last_Name,' ') Var_Last_Nmae,
Nvl(Ppa.Last_Name2,' ') Var_Last_Name2,
Nvl(Ppa.Middle_Name,' ') Var_Middle_Name,
Nvl(Pfl.Display_Name,' ') Var_Display_Name,
Nvl(Addr.Street1,' ') Var_Street1,
Nvl(Addr.Street2,' ') Var_Street2,
Nvl(Addr.City,' ') Var_City ,
Nvl(Addr.State_Name,' ') Var_State_Name,
Addr.Post_Code Var_Post_Code,
Nvl(Cnt.Cntry_Name,' ') Var_Country,
Phn.Phone Var_Phone_Nbr,
Nvl(To_Char(Ppa.Birthdate,'MON/DD/YYYY'),' ') Var_Birthdate,
Nvl(Ppa.Occupation,' ') Var_Occupation,
Nvl(Ppa.Country_Of_Nationality,1) Var_Country_Of_Nationality,
Nvl(Ppa2.First_Name,' ') Var_First_Name,
Nvl(Ppa2.Last_Name,' ') Var_Last_Nmae,
Nvl(Ppa2.Last_Name2,' ') Var_Last_Name2,
Nvl(Ppa2.Middle_Name,' ') Var_Middle_Name,
Nvl(Pfl2.Display_Name,' ') Var_Display_Name,
Nvl(Addr2.Street1,' ') Var_Street1,
Nvl(Addr2.Street2,' ') Var_Street2,
Nvl(Addr2.City,' ') Var_City ,
Nvl(Addr2.State_Name,' ') Var_State_Name,
Addr2.Post_Code Var_Post_Code,
Nvl(Cnt2.Cntry_Name,' ') Var_Country,
Phn2.Phone Var_Phone_Nbr,
Nvl(To_Char(Ppa2.Birthdate,'MON/DD/YYYY'),' ') Var_Birthdate,
Nvl(Ppa2.Occupation,' ') Var_Occupation,
Nvl(ppa2.COUNTRY_OF_NATIONALITY,1) var_COUNTRY_OF_NATIONALITY
From
V_Xact_Receiver Xrc, V_Person_Profile Ppa, V_Profile Pfl,V_Phone Phn,V_Address Addr,V_Country_Lu Cnt
,V_Xact_sender xsr, V_Person_Profile Ppa2, V_Profile Pfl2,V_Phone Phn2,V_Address Addr2,V_Country_Lu Cnt2
Where Xrc.Xact_Hdr_Nbr=71138142
and xsr.Xact_Hdr_Nbr=71138142
And xrc.Profile_Nbr=Ppa.Profile_Nbr
And Ppa.Profile_Nbr=Pfl.Profile_Nbr
And Pfl.Profile_Nbr=Phn.Profile_Nbr
And Pfl.Profile_Nbr=Addr.Profile_Nbr
And Phn.Country_Nbr=Cnt.Country_Nbr
And Xsr.Profile_Nbr=Ppa2.Profile_Nbr
And Ppa2.Profile_Nbr=Pfl2.Profile_Nbr
And Pfl2.Profile_Nbr=Phn2.Profile_Nbr
And Pfl2.Profile_Nbr=Addr2.Profile_Nbr
And Phn2.Country_Nbr=Cnt2.Country_Nbr;
and
SELECT
Nvl(Dlu.Id_Type_Desc,' ') Var_Ident_Type_Desc,
Nvl(D.Id_Number,' ') Var_Id_Number,
Nvl(To_Char(D.Id_Issue_Date,'MON/DD/YYYY'),' ') Dte_Id_Issue,
Nvl(To_Char(D.Id_Expiration_Date,'MON/DD/YYYY'),' ') Dte_Id_Expiration,
Nvl(To_Char(Id_Expiration_Date,'MON/DD/YYYY'),' ') Dte_Id_Expiration,
Nvl(D.Id_Issue_Place,' ') Var_Issue_Loc,
Nvl(Pfl.Occupation,' ') Var_Occupation,
Nvl(To_Char(Pfl.Birthdate,'MON/DD/YYYY'),' ') Dte_Birth,
Nvl(To_Char(Pfl.Country_Of_Nationality,'MON/DD/YYYY'),' ') Var_Country_Of_Nationality
FROM V_PROFILE_IDENT D,
V_ID_TYPE_LU DLU,
V_Country_Lu Clu,
V_Xact_sender Xsr,
v_person_profile pfl
Where Xsr.Xact_Hdr_Nbr='71138142'
And D.Profile_Nbr = Xsr.Profile_Nbr
and D.Profile_Nbr=pfl.Profile_Nbr
And D.Id_Type_Nbr = Dlu.Id_Type_Nbr
And D.Country_Nbr = Clu.Country_Nbr(+)
And D.Is_Valid = 'Y'
and rownum<=3;
The first query it returns the result in a single row
The second query it returns the output in 3 rows
while i was club these two it gives the result in 3 rows
but have to get the result in a single row with all appropriate values side by side if the values are same get the values one only
and the query club as
Select
Xrc.Profile_Nbr Var_Profile_Nbr,
xsr.Profile_Nbr Var_Profile_Nbr,
Nvl(Ppa.First_Name,' ') Var_First_Name,
Nvl(Ppa.Last_Name,' ') Var_Last_Nmae,
Nvl(Ppa.Last_Name2,' ') Var_Last_Name2,
Nvl(Ppa.Middle_Name,' ') Var_Middle_Name,
Nvl(Pfl.Display_Name,' ') Var_Display_Name,
Nvl(Addr.Street1,' ') Var_Street1,
Nvl(Addr.Street2,' ') Var_Street2,
Nvl(Addr.City,' ') Var_City ,
Nvl(Addr.State_Name,' ') Var_State_Name,
Addr.Post_Code Var_Post_Code,
Nvl(Cnt.Cntry_Name,' ') Var_Country,
Phn.Phone Var_Phone_Nbr,
Nvl(To_Char(Ppa.Birthdate,'MON/DD/YYYY'),' ') Var_Birthdate,
Nvl(Ppa.Occupation,' ') Var_Occupation,
Nvl(Ppa.Country_Of_Nationality,1) Var_Country_Of_Nationality,
Nvl(Ppa2.First_Name,' ') Var_First_Name,
Nvl(Ppa2.Last_Name,' ') Var_Last_Nmae,
Nvl(Ppa2.Last_Name2,' ') Var_Last_Name2,
Nvl(Ppa2.Middle_Name,' ') Var_Middle_Name,
Nvl(Pfl2.Display_Name,' ') Var_Display_Name,
Nvl(Addr2.Street1,' ') Var_Street1,
Nvl(Addr2.Street2,' ') Var_Street2,
Nvl(Addr2.City,' ') Var_City ,
Nvl(Addr2.State_Name,' ') Var_State_Name,
Addr2.Post_Code Var_Post_Code,
Nvl(Cnt2.Cntry_Name,' ') Var_Country,
Phn2.Phone Var_Phone_Nbr,
Nvl(To_Char(Ppa2.Birthdate,'MON/DD/YYYY'),' ') Var_Birthdate,
Nvl(Ppa2.Occupation,' ') Var_Occupation,
Nvl(Ppa2.Country_Of_Nationality,1) Var_Country_Of_Nationality,
Nvl(Dlu.Id_Type_Desc,' ') Var_Ident_Type_Desc,
Nvl(D.Id_Number,' ') Var_Id_Number,
Nvl(To_Char(D.Id_Issue_Date,'MON/DD/YYYY'),' ') Dte_Id_Issue,
Nvl(To_Char(D.Id_Expiration_Date,'MON/DD/YYYY'),' ') Dte_Id_Expiration,
Nvl(To_Char(Id_Expiration_Date,'MON/DD/YYYY'),' ') Dte_Id_Expiration,
Nvl(D.Id_Issue_Place,' ') Var_Issue_Loc,
Nvl(Pfl3.Occupation,' ') Var_Occupation,
Nvl(To_Char(Pfl3.Birthdate,'MON/DD/YYYY'),' ') Dte_Birth,
Nvl(To_Char(Pfl3.Country_Of_Nationality,'MON/DD/YYYY'),' ') Var_Country_Of_Nationality
From
V_Xact_Receiver Xrc, V_Person_Profile Ppa, V_Profile Pfl,V_Phone Phn,V_Address Addr,V_Country_Lu Cnt
,V_Xact_sender xsr, V_Person_Profile Ppa2, V_Profile Pfl2,V_Phone Phn2,V_Address Addr2,V_Country_Lu Cnt2
V_Profile_Ident D,
V_Id_Type_Lu Dlu,
V_Country_Lu Clu,
V_Xact_receiver Xrc2,
v_person_profile pfl3
Where Xrc.Xact_Hdr_Nbr=71138142
And Xsr.Xact_Hdr_Nbr=71138142
and xrc2.Xact_Hdr_Nbr=71138142
And xrc.Profile_Nbr=Ppa.Profile_Nbr
And Ppa.Profile_Nbr=Pfl.Profile_Nbr
And Pfl.Profile_Nbr=Phn.Profile_Nbr
And Pfl.Profile_Nbr=Addr.Profile_Nbr
And Phn.Country_Nbr=Cnt.Country_Nbr
And Xsr.Profile_Nbr=Ppa2.Profile_Nbr
And Ppa2.Profile_Nbr=Pfl2.Profile_Nbr
And Pfl2.Profile_Nbr=Phn2.Profile_Nbr
And Pfl2.Profile_Nbr=Addr2.Profile_Nbr
And Phn2.Country_Nbr=Cnt2.Country_Nbr
And D.Profile_Nbr = Xrc2.Profile_Nbr
and D.Profile_Nbr=pfl3.Profile_Nbr
And D.Id_Type_Nbr = Dlu.Id_Type_Nbr
And D.Country_Nbr = Clu.Country_Nbr(+)
And D.Is_Valid = 'Y'
and rownum<=3;
regards,

Similar Messages

  • Display data in single row

    i have table dept of deptno d001,d002,d003,d004
    i want to list the data like below
    deptno
    d001,d002,d003,d004 ( in a single row)
    is it possible..?
    S

    Based on your database version you can try any one of the following http://www.oracle-base.com/articles/misc/StringAggregationTechniques.php

  • Alternative way to fetch the data into single row.

    we have a query
    SELECT COLUMN_NAME FROM USER_TAB_COLUMNS WHERE TABLE_NAME='XXX';
    This query will return the data in multiple rows.
    May know the alternative way to retrieve all the multiple rows in **single row with each row as a seperate column**.

    Why specifically an array - and do you want the SQL projection as an array, or collect the SQL projection into an array?
    E.g.
    SQL> create or replace type TStrings is table of varchar2(4000);
      2  /
    Type created.
    SQL> --// SQL projection casted into an array
    SQL> select
      2          cast(
      3                  MultiSet(
      4                          select column_name from all_tab_columns where table_name = 'KU$_DATAPUMP_MASTER_11_2' and owner = 'SYS'
      5                  )
      6                  as TStrings
      7          )                       as COLUMN_ARRAY
      8  from       dual
      9  /
    COLUMN_ARRAY
    TSTRINGS('REMOTE_LINK', 'VERSION', 'JOB_VERSION', 'DB_VERSION', 'TIMEZONE', 'STATE', 'PHASE', 'GUID', 'START_TIME', 'BLOCK_SIZE', 'METADATA_BUFFER_SIZE', 'DATA_BUFFER_SIZE', 'DEGREE', 'PLATFORM', 'ABO
    RT_STEP', 'INSTANCE', 'CLUSTER_OK', 'SERVICE_NAME', 'OBJECT_INT_OID', 'PROCESS_ORDER', 'DUPLICATE', 'DUMP_FILEID', 'DUMP_POSITION', 'DUMP_LENGTH', 'DUMP_ORIG_LENGTH', 'DUMP_ALLOCATION', 'COMPLETED_ROW
    S', 'ERROR_COUNT', 'ELAPSED_TIME', 'OBJECT_TYPE_PATH', 'OBJECT_PATH_SEQNO', 'OBJECT_TYPE', 'IN_PROGRESS', 'OBJECT_NAME', 'OBJECT_LONG_NAME', 'OBJECT_SCHEMA', 'ORIGINAL_OBJECT_SCHEMA', 'ORIGINAL_OBJECT
    _NAME', 'PARTITION_NAME', 'SUBPARTITION_NAME', 'DATAOBJ_NUM', 'FLAGS', 'PROPERTY', 'TRIGFLAG', 'CREATION_LEVEL', 'COMPLETION_TIME', 'OBJECT_TABLESPACE', 'SIZE_ESTIMATE', 'OBJECT_ROW', 'PROCESSING_STAT
    E', 'PROCESSING_STATUS', 'BASE_PROCESS_ORDER', 'BASE_OBJECT_TYPE', 'BASE_OBJECT_NAME', 'BASE_OBJECT_SCHEMA', 'ANCESTOR_PROCESS_ORDER', 'DOMAIN_PROCESS_ORDER', 'PARALLELIZATION', 'UNLOAD_METHOD', 'LOAD
    _METHOD', 'GRANULES', 'SCN', 'GRANTOR', 'XML_CLOB', 'PARENT_PROCESS_ORDER', 'NAME', 'VALUE_T', 'VALUE_N', 'IS_DEFAULT', 'FILE_TYPE', 'USER_DIRECTORY', 'USER_FILE_NAME', 'FILE_NAME', 'EXTEND_SIZE', 'FI
    LE_MAX_SIZE', 'PROCESS_NAME', 'LAST_UPDATE', 'WORK_ITEM', 'OBJECT_NUMBER', 'COMPLETED_BYTES', 'TOTAL_BYTES', 'METADATA_IO', 'DATA_IO', 'CUMULATIVE_TIME', 'PACKET_NUMBER', 'INSTANCE_ID', 'OLD_VALUE', '
    SEED', 'LAST_FILE', 'USER_NAME', 'OPERATION', 'JOB_MODE', 'QUEUE_TABNUM', 'CONTROL_QUEUE', 'STATUS_QUEUE')
    SQL> --// collecting the SQL projection as an array
    SQL> declare
      2          colArray        TStrings;
      3  begin
      4          select
      5                  column_name bulk collect into colArray
      6          from    all_tab_columns
      7          where   table_name = 'KU$_DATAPUMP_MASTER_11_2'
      8          and     owner = 'SYS';
      9 
    10          --// process array
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL>

  • Converting multi-row data to single row

    My source table has one or more records with the same id. My destination table only has one record for each id. I wish to combine the records from my source table to my destination table. I think the following query will show what I'm trying to do:
    update TARGET_TABLE
    set (A)
    =
    (select (case
    when sum(A*FUEL_TYPE_ID) > 2 then 4
    else sum(A*FUEL_TYPE_ID)
    end)
    from SOURCE_TABLE
    group by additive_id)
    where additive_id = NEW_TABLE.additive_idSince I'm currently limited to Apex SQL Commands, the error information is minimalist:
    ORA-01427: single-row subquery returns more than one row
    How should I be doing this?

    Hi tharpa,
    Are u able to relate to this.
    create table emp2 as select * from emp;
      update emp2
      set sal=(
                  select sum(sal)
                   from emp
                   group by deptno)
    where   empno=7839
    -------correct one would be-------
       update emp2 e2
       set sal=(
                 select sum(sal)
                  from emp e1
                  where e1.deptno=e2.deptno
                  group by deptno)
        where   empno=7839
         Hope it helps
    CKLP
    Edited by: CKLP on Apr 11, 2011 5:17 AM

  • How to get multiple row data in single row for one value of foreign key

    i want to get data from a table in a way that all the emp_id corresponding to one manager_id
    in employee table come in one row. (emp_id is the primary key and manager_id is the foreign key) Since there are different emp_id whose manager_id is same
    so how can i get all the emp_id in one row .

    One way with 10g:
    select mgr,
           rtrim(xmlagg(xmlelement(empno,empno||',').extract('//text()')),',')  emps
    from emp
    where mgr is not null
    group by mgr;10g:
    -- define this function:
    create or replace
    function concatenate(c Sys_refcursor, sep varchar2 default null) return varchar2
    as
      val varchar2(100);
      return_value varchar2(4000);
    begin
    --  open c;
      loop
      fetch c into val;
      exit when c%notfound;
      if return_value is null then
        return_value:=val;
      else
        return_value:=return_value||sep||val;
      end if;
      end loop;
      return return_value;
    end;
    select mgr,
           concatenate(cursor(select empno from emp e where e.mgr=emp.mgr order by empno),',')
    from emp
    where mgr is not null
    group by mgr;With 11g:
    select mgr,
           listagg(empno,',') within group (order by empno) emps
    from emp
    where mgr is not null
    group by mgr;

  • Edit data in single row

    I'm busy re-oredering data.
    I have the follwing problem:
    I've a column with data that must become unique, but there are values that occur more than once. I've to append 0, 1,2, etc to these values in order to make the values unique.
    eg.
    [b]Current situation
    aplha
    alpha
    alpha
    Desired
    alpha1
    alpha2
    alpha3
    how can I realize this in PL/SQL? tnx in advance.

    Similar:
    SQL> INSERT INTO emp
       SELECT 9999 empno,
              ename,
              job,
              mgr,
              hiredate,
              sal,
              comm,
              40 deptno
         FROM emp
        WHERE empno = 7788
    1 row created.
    SQL> SELECT deptno,
           deptno || DECODE (cnt, 1, NULL, rn) new_deptno
      FROM (SELECT deptno,
                   ROW_NUMBER () OVER (PARTITION BY deptno ORDER BY deptno) rn,
                   COUNT (*) OVER (PARTITION BY deptno) cnt
              FROM emp)
        DEPTNO NEW_D
            10 101 
            10 102 
            10 103 
            20 201 
            20 202 
            20 203 
            20 204 
            20 205 
            30 301 
            30 302 
            30 303 
            30 304 
            30 305 
            30 306 
            40 40  
    15 rows selected.

  • How to manipulate data in multiple rows without using cursor??

    Hi all,
    I have a form in which there is a push button & 4 text fields.
    Push button : Process
    Text fields: Year, Month, Financial_To_Year, Financial_From_Date.
    In database , there are tables like, CUSTOMER_MASTER, FD_ACCOUNT_MASTER, FD_ACCOUNT_DTL, CUSTOMER_YEARLY_INTEREST, etc.
    In table FD_ACCOUNT_MASTER, there are columns, like CUST_CODE, FD_ACCT_NO, FD_AMOUNT, ACCT_OPEN_DT, ACCT_CLOSE_DATE, ACCT_TYPE, INTEREST_RATE, etc.
    There are thousands of records in the table.
    For Push button : Process , TRIGGER: When button pressed,
    I have to do all the process of FD for all the FD_ACCOUNTS at once. Process means i have to calculate Interest for all the accounts, calculate interest monthly, quarterly, yearly and make the FD_Accounts disable after the date of ACCT_CLOSE_DATE is reached, make the accounts renewed , etc all the process.
    But to do this process for multiple rows at once, we use cursor, but i don't want to use cursor as i feel its too tedious to do.
    Is there any other way , where i do process of multiple records at once without using cursor??
    Help me, Thank You.
    Oracle Forms Builder 6i.
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

    An Update statement certainly can update sets of data instead single row updates:
    UPDATE Statement
    if you can't do it in a single statement you can use bulk processing as well:
    PLSQL 101
    cheers

  • Combining Multiple Rows into single row with multple columns

    Hi Experts,
    I have the following requirement, kindly help me.
    I have data in my table like below.
    ID NAME DEPT
    1 Sam 10
    1 Sam 20
    2 alex     30
    2 alex 40
    2 alex 50
    3 vinod 60
    3 vinod 70
    I want to show the same data into single row with dynamically generating columns for DEPT. I want show like below.
    ID NAME DEPT1 DEPT2 DEPT3
    1 Sam 10 20
    2 alex 30 40 50
    3 vinod 60 70
    It's urgent requirement, kindly help me.
    Thanks in advance.

    Right I've had my drink, so what was this "urgent" question then?
    798616 wrote:
    I have data in my table like below.
    ID NAME DEPT
    1 Sam 10
    1 Sam 20
    2 alex     30
    2 alex 40
    2 alex 50
    3 vinod 60
    3 vinod 70
    I want to show the same data into single row with dynamically generating columns for DEPT. I want show like below.Dynamic numbers of columns eh! Tricky.
    If you understand how SQL statements are executed it's along these lines...
    1. Open Cursor
    2. Parse SQL statement and determine columns
    3. Bind in any input values
    4. Fetch data
    5. Bind out values to columns
    6. Repeat step 3 until no more data
    7. Close cursor
    Now, you're expecting that you can determine the columns (step 2) from the fetched data (step 4 onwards). You can't. The SQL engine needs to know the expected columns before any data is fetched so, it can't base the number of columns on the data itself.
    If you need that requirement, you would need to query the data first and build up a dynamic query based on the data and then execute that dynamically built query to fetch the data and pivot it into those columns, which means that you have queried the data twice. Not good practice and not good (or simple) coding.
    What you're talking of doing is something that should be handled at the presentation/interface layer, not as part of the data fetch.
    Typically these sorts of things are handled most easily in report generation/writer tools such as Oracle Reports, Business Objects etc. where they fetch the data from the database and then process it to format it on the display, pivoting the results as required.
    It's not something that lends itself to be easily achieved in SQL. Yes, SQL can do pivoting of data quite easily, but NOT with a dynamic number of columns.
    If you were to specify that there is a maximum number of columns that you could get (rather than wanting it dynamic), then you can do it simply in SQL with the max-decode method...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select deptno, ename, row_number() over (partition by deptno order by ename) as rn from emp)
      2  --
      3  select deptno
      4        ,max(decode(rn,1,ename)) as ename1
      5        ,max(decode(rn,2,ename)) as ename2
      6        ,max(decode(rn,3,ename)) as ename3
      7        ,max(decode(rn,4,ename)) as ename4
      8        ,max(decode(rn,5,ename)) as ename5
      9        ,max(decode(rn,6,ename)) as ename6
    10        ,max(decode(rn,7,ename)) as ename7
    11        ,max(decode(rn,8,ename)) as ename8
    12        ,max(decode(rn,9,ename)) as ename9
    13        ,max(decode(rn,10,ename)) as ename10
    14  from t
    15  group by deptno
    16* order by deptno
    SQL> /
        DEPTNO ENAME1     ENAME2     ENAME3     ENAME4     ENAME5     ENAME6     ENAME7     ENAME8     ENAME9     ENAME10
            10 CLARK      KING       MILLER
            20 ADAMS      FORD       JONES      SCOTT      SMITH
            30 ALLEN      BLAKE      JAMES      MARTIN     TURNER     WARD
    SQL>

  • Display of data in a single row

    Hi
    Here is my query:
    SELECT
    --Element Classification Details:
    pec.CLASSIFICATION_ID,
    pec.classification_name,
    pec1.classification_id "Sub Classification Id",
    DECODE(pec1.classification_name,'Other Deductions', 'Other Deductions',
    'Others Voluntary Deductions', 'Other Deductions',
    'Personal Deductions', 'Personal Deductions',
    'Personal Voluntary Deductions', 'Personal Deductions',
    'Car Loan Deductions') "Sub Classification",
    pec1.parent_classification_id,
    scr.sub_classification_rule_id,
    --Element Details:
    pet.element_name, pet.element_type_id, pet.reporting_name,
    DECODE(pet.processing_type, 'R', 'Recurring', 'Nonrecurring') "Processing Type",
    pet.EFFECTIVE_START_DATE, pet.EFFECTIVE_END_DATE,
    --Run Result Details:
    prr.run_result_id,
    TO_NUMBER(NVL(prrv.RESULT_VALUE, 0)) "Amount",
    piv.NAME "Input Value",
    --Assignment Details:
    paa.assignment_id,
    --Time Period
    ptp.START_DATE, ptp.end_date,
    ptp.period_name "Payroll Period"
    FROM hr.pay_element_classifications pec,
    hr.pay_element_classifications pec1,
    hr.pay_sub_classification_rules_f scr,
    hr.pay_element_types_f pet,
    hr.pay_run_results prr,
    hr.pay_run_result_values prrv,
    hr.pay_input_values_f piv,
    hr.pay_assignment_actions assact,
    hr.per_all_assignments_f paa,
    hr.pay_payroll_actions payroll,
    hr.per_time_periods ptp
    WHERE
    pec.classification_id = pec1.parent_classification_id (+)
    AND scr.classification_id = pec1.classification_id
    AND pet.classification_id = pec.classification_id
    AND scr.element_type_id = pet.element_type_id
    AND pet.ELEMENT_TYPE_ID = prr.ELEMENT_TYPE_ID
    AND prr.run_result_id = prrv.run_result_id
    AND piv.input_value_id = prrv.input_value_id
    AND assact.ASSIGNMENT_ACTION_ID = prr.ASSIGNMENT_ACTION_ID
    AND paa.ASSIGNMENT_ID = assact.ASSIGNMENT_ID
    AND payroll.payroll_action_id = assact.PAYROLL_ACTION_ID
    AND ptp.TIME_PERIOD_ID = payroll.time_period_id
    AND ptp.end_date BETWEEN scr.EFFECTIVE_START_DATE AND scr.EFFECTIVE_END_DATE
    AND ptp.end_date BETWEEN pet.effective_start_date AND pet.effective_end_date
    AND ptp.end_date BETWEEN paa.EFFECTIVE_START_DATE AND paa.EFFECTIVE_END_DATE
    AND pec.CLASSIFICATION_NAME IN ('Voluntary Deductions', 'Pre-Tax Deductions')
    AND pec1.classification_name LIKE '%Deduction%'
    AND piv.name = 'Pay Value'
    AND paa.payroll_id != 0
    AND paa.pay_basis_id != 0
    AND paa.ASSIGNMENT_ID = '560'
    I needed to display the amounts as separate columns pertaining to different elements or rather different sub classification of the elements
    This is the final expected result for the report:
    Employee Personal Deductions PD Amount Other Deductions OD Amt
    XYZ Element1 00000.00 Element3 0000.00
    Element 2
    Car Loan Deductions CLD Amt Total Deductions (Total of all three)
    Element4 00000.00 00000000.00
    Here Personal Deductions, Other, Car Loan etc. are grouping of elements (sub classifications)
    I have used MAX function to display the results as separate columns like this:
    SELECT
    --Run Result Details:
    prr.run_result_id,
    MAX(DECODE(pec1.classification_name, 'Personal Deductions', TO_NUMBER(NVL(prrv.RESULT_VALUE, 0)))) "Personal Deductions",
    MAX(DECODE(pec1.classification_name, 'Personal Voluntary Deductions', TO_NUMBER(NVL(prrv.RESULT_VALUE, 0)))) "Personal V Deductions",
    MAX(DECODE(pec1.classification_name, 'Other Deductions', TO_NUMBER(NVL(prrv.RESULT_VALUE, 0)))) "Other Deductions",
    MAX(DECODE(pec1.classification_name, 'Others Voluntary Deductions', TO_NUMBER(NVL(prrv.RESULT_VALUE, 0)))) "Others V Deductions",
    MAX(DECODE(pec1.classification_name, 'Car Loan Deductions', TO_NUMBER(NVL(prrv.RESULT_VALUE, 0)))) "Car Loan Deductions"
    /*--Assignment Details:
    paa.assignment_id,
    --Time Period
    ptp.START_DATE, ptp.end_date,
    ptp.period_name "Payroll Period"*/
    FROM hr.pay_element_classifications pec,
    hr.pay_element_classifications pec1,
    hr.pay_sub_classification_rules_f scr,
    hr.pay_element_types_f pet,
    hr.pay_run_results prr,
    hr.pay_run_result_values prrv,
    hr.pay_input_values_f piv
    /*hr.pay_assignment_actions assact,
    hr.per_all_assignments_f paa,
    hr.pay_payroll_actions payroll,
    hr.per_time_periods ptp*/
    WHERE
    pec.classification_id = pec1.parent_classification_id (+)
    AND scr.classification_id = pec1.classification_id
    AND pet.classification_id = pec.classification_id
    AND scr.element_type_id = pet.element_type_id
    AND pet.ELEMENT_TYPE_ID = prr.ELEMENT_TYPE_ID
    AND prr.run_result_id = prrv.run_result_id
    AND piv.input_value_id = prrv.input_value_id
    /*AND assact.ASSIGNMENT_ACTION_ID = prr.ASSIGNMENT_ACTION_ID
    AND paa.ASSIGNMENT_ID = assact.ASSIGNMENT_ID
    AND payroll.payroll_action_id = assact.PAYROLL_ACTION_ID
    AND ptp.TIME_PERIOD_ID = payroll.time_period_id
    --and pet.element_NAME like 'IVTB%' 
    AND ptp.end_date BETWEEN scr.EFFECTIVE_START_DATE AND scr.EFFECTIVE_END_DATE
    AND ptp.end_date BETWEEN pet.effective_start_date AND pet.effective_end_date
    AND ptp.end_date BETWEEN paa.EFFECTIVE_START_DATE AND paa.EFFECTIVE_END_DATE*/
    AND pec.CLASSIFICATION_NAME IN ('Voluntary Deductions', 'Pre-Tax Deductions')
    AND pec1.classification_name LIKE '%Deduction%'
    AND piv.name = 'Pay Value'
    --and paa.PRIMARY_FLAG like 'Y%'
    /*AND paa.payroll_id != 0
    AND paa.pay_basis_id != 0*/
    GROUP BY
    prr.run_result_id
    However, the fact is that my each element_type_id has each run_result_id, which means 1 element has 1 run result id. Thus, I cannot display the data in a single row.
    Can someone guide me on this? How can I display the data for an employee as a single row?
    Thanks and regards,
    Aparna

    SELECT EMP_ID,
         Sum(Decode(DECODE(pec1.classification_name,'Other Deductions', 'Other Deductions','Others Voluntary Deductions', 'Other Deductions'),'Other Deductions',TO_NUMBER(NVL(prrv.RESULT_VALUE, 0)))) 'Other deduction',
         sum(Decode(DECODE(pec1.classification_name,'Personal Deductions', 'Personal Deductions', 'Personal Voluntary Deductions', 'Personal Deductions'),'Personal Deductions'),TO_NUMBER(NVL(prrv.RESULT_VALUE, 0)))) 'Personal deduction',
         sum(DECODE(pec1.classification_name,'Car Loan Deductions',TO_NUMBER(NVL(prrv.RESULT_VALUE, 0)))) 'Car deduction'
    FROM hr.pay_element_classifications pec,
    hr.pay_element_classifications pec1,
    hr.pay_sub_classification_rules_f scr,
    hr.pay_element_types_f pet,
    hr.pay_run_results prr,
    hr.pay_run_result_values prrv,
    hr.pay_input_values_f piv,
    hr.pay_assignment_actions assact,
    hr.per_all_assignments_f paa,
    hr.pay_payroll_actions payroll,
    hr.per_time_periods ptp
    WHERE
    pec.classification_id = pec1.parent_classification_id (+)
    AND scr.classification_id = pec1.classification_id
    AND pet.classification_id = pec.classification_id
    AND scr.element_type_id = pet.element_type_id
    AND pet.ELEMENT_TYPE_ID = prr.ELEMENT_TYPE_ID
    AND prr.run_result_id = prrv.run_result_id
    AND piv.input_value_id = prrv.input_value_id
    AND assact.ASSIGNMENT_ACTION_ID = prr.ASSIGNMENT_ACTION_ID
    AND paa.ASSIGNMENT_ID = assact.ASSIGNMENT_ID
    AND payroll.payroll_action_id = assact.PAYROLL_ACTION_ID
    AND ptp.TIME_PERIOD_ID = payroll.time_period_id
    AND ptp.end_date BETWEEN scr.EFFECTIVE_START_DATE AND scr.EFFECTIVE_END_DATE
    AND ptp.end_date BETWEEN pet.effective_start_date AND pet.effective_end_date
    AND ptp.end_date BETWEEN paa.EFFECTIVE_START_DATE AND paa.EFFECTIVE_END_DATE
    AND pec.CLASSIFICATION_NAME IN ('Voluntary Deductions', 'Pre-Tax Deductions')
    AND pec1.classification_name LIKE '%Deduction%'
    AND piv.name = 'Pay Value'
    AND paa.payroll_id != 0
    AND paa.pay_basis_id != 0     
    I hope this may help!
    Brijesh

  • SQL Update a Single Row Multiple Times Using 2 Data Sets

    I'm working in tsql and have an issue where I need to do multiple updates to a single row based on multiple conditions. 
    By Rank_
    If the column is NULL I need it to update no matter what the Rank is.
    If the Ranks are the same I need it to update in order of T2_ID.
    And I need it to use the last updated output.
    I've tried using the update statement below but it only does the first update and the rest are ignored. Here is an example of the data sets i'm working w/ and the Desired results. Thanks in advance!
    update a
    set Middle = case when a.Rank_> b.Rank_ OR a.Middle IS NULL then ISNULL(b.Middle,a.Middle) end,
    LName = case when a.Rank_> b.Rank_ OR a.Lname IS NULL then ISNULL(b.LName,a.LName) end,
    Rank_ = case when a.Rank_> b.Rank_ then b.Rank_ end
    from #temp1 a
    inner join #temp2 b on a.fname = b.fname
    where b.T2_ID in (select top 100% T2_ID from #temp2 order by T2_ID asc)

    The Merge clause actually errors because it attempt to update the same record.  I think this CTE statement is the closest I've come but I'm still working through it as I'm not too familiar w/ them.  It returns multiple rows which I will have to
    insert into a temp table to update since the resulting row I need is the last in the table.
    ;WITH cteRowNumber
    AS(
    Select DISTINCT
    Row_Number() OVER(PARTITION BY a.LName ORDER BY a.LName ASC, a.Rank_ DESC,b.T2ID ASC) AS RowNumber
    ,a.FName
    ,a.LName
    ,b.LName as xLname
    ,a.MName
    ,b.MName AS xMName
    ,a.Rank_
    ,b.Rank_ AS xRank
    ,b.T2ID
    FROM #temp1 a
    inner join #temp2 b
    ON a.fname = b.fname
    ), cteCursor
    AS(
    Select a.RowNumber,
    a.Fname
    ,a.LName
    ,a.xLname
    ,a.MName
    ,a.xMName
    ,a.xRank
    ,a.T2ID
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xRank,a.Rank_) else ISNULL(a.Rank_,a.xRank) end AS Alt_Rank_
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xMName,a.MName) else ISNULL(a.MName,a.xMName) end AS Alt_MName
    ,CASE WHEN a.Rank_ >= a.xRank THEN ISNULL(a.xLName,a.lname) else ISNULL(a.LName,a.xlname) end as Alt_Lname
    FROM cteRowNumber a
    where a.RowNumber = 1
    UNION ALL
    Select crt.RowNumber
    ,crt.FName
    ,crt.LName
    ,crt.xLname
    ,crt.MName
    ,crt.xMName
    ,crt.xRank
    ,crt.T2ID
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xRank,Prev.Alt_Rank_) else ISNULL(Prev.Alt_Rank_,crt.xRank) end AS Alt_Rank
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xMName,Prev.Alt_MName) else ISNULL(Prev.Alt_MName,crt.xMName) end AS Alt_MName
    ,CASE WHEN Prev.Alt_Rank_ >= crt.xRank THEN ISNULL(crt.xLName,Prev.Alt_Lname) else ISNULL(Prev.Alt_Lname,crt.xLName) end as Alt_Lname
    FROM cteCursor prev
    inner join cteRowNumber crt
    on prev.fname = crt.fname and prev.RowNumber + 1 = crt.RowNumber
    SELECT cte.*
    FROM cteCursor cte

  • Multiple clobs in a single row of data

    I have several clobs in a single row of data and have created a procedure where I attempt to display the first 4k of each clob.
    using a for loop cursor I select all of the clobs in a row at the same time and then I use dbms_lob.read to get the first 4k of data.
    For the first lob of each row everything works fine but when I attempt to dbms_lob.read the second one I get an "ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275" and I'm not sure why?
    does anyone know of an example where two or more clobs are selected and then converted to 4K varchars?
    sample columns for the table:
    SPECIALREQUIREMENTSS     CLOB
    REFERENCERANGE     CLOB
    ALERTVALUE     CLOB
    REFERENCELAB     VARCHAR2(50 CHAR)
    TESTINCLUDES     CLOB
    LASTUPDATE     DATE
    sample code (I removed some code for clairity - this produces the same error):
    create or replace
    procedure test_lobs as
    v_lab_blob blob;
    v_lobamt binary_integer := 32767;
    v_lobpos pls_integer := 1;
    v_labrec labman.lab_testingdata%rowtype;
    v_buffer varchar2(32767) :='';
    v_start_left number;
    begin
    -- *** housekeeping
    dbms_lob.createtemporary(v_labrec.testincludes,TRUE);
    dbms_lob.createtemporary(v_labrec.specialrequirementss,TRUE);
    Plpdf.init;
    Plpdf.NewPage;
    Plpdf.SetColor4Drawing(66,66,66);
    Plpdf.SetColor4Filling(180,180,180);
    v_start_left := Plpdf.GetPageWidth-Plpdf.GetPageRightSpace;
    -- *** select the test name for shaded printing
    for x in (select indexnumber, test from labman.lab_testingdata where test like 'A%') loop
    -- *** select the test data for printing
    select * into v_labrec from labman.lab_testingdata where indexnumber = x.indexnumber;
    -- *** test includes
    if dbms_lob.getlength(v_labrec.testincludes) > 0 or v_labrec.testincludes is not null then
    Plpdf.SetPrintFont('Arial','B',8);
    Plpdf.LineBreak(.1);
    Plpdf.PrintCell(25,5,'Test Includes:',0,0,'R',0,null,0);
    Plpdf.SetPrintFont('Arial',null,8);
    if dbms_lob.getlength(v_labrec.testincludes) > 32767 then
    v_buffer := '*** error - text is greater than 32k ***';
    else
    v_lobamt := 32767;
    v_buffer := '';
    dbms_lob.read(v_labrec.testincludes,v_lobamt,v_lobpos,v_buffer);
    end if;
    Plpdf.SetLeftMargin(Plpdf.GetCurrentX);
    Plpdf.PrintFlowingText(5,v_buffer,null,0);
    Plpdf.SetLeftMargin(v_start_left);
    Plpdf.lineBreak;
    end if;
    -- *** special requirements
    Plpdf.SetPrintFont('Arial','B',8);
    Plpdf.LineBreak(.1);
    Plpdf.PrintCell(25,5,'Special Requirements:',0,0,'R',0,null,0);
    Plpdf.SetPrintFont('Arial',null,8);
    if dbms_lob.getlength(v_labrec.specialrequirementss) > 32767 then
    v_buffer := '*** error - text is greater than 32k ***';
    elsif dbms_lob.getlength(v_labrec.specialrequirementss) = 0 then
    v_buffer := '';
    else
    v_lobamt := 32767;
    v_buffer := '';
    dbms_lob.read(v_labrec.specialrequirementss,v_lobamt,v_lobpos,v_buffer);
    end if;
    Plpdf.SetLeftMargin(Plpdf.GetCurrentX);
    Plpdf.PrintFlowingText(5,v_buffer,null,0);
    Plpdf.SetLeftMargin(v_start_left);
    Plpdf.lineBreak;
    commit;
    end loop;
    Plpdf.SendDoc(v_lab_blob);
    -- store the PDF document
    delete from store_blob;
    commit;
    INSERT INTO STORE_BLOB (blob_file, created_date)
    VALUES (v_lab_blob, SYSDATE);
    COMMIT;
    end test_lobs;

    didn't think that checking for a length of zero and null would produce two different results - should have known better.
    Thanks for your help!
    elsif dbms_lob.getlength(v_labrec.specialrequirementss) = 0
    or v_labrec.specialrequirementss is null then

  • Data Populated in a single row??

    Hi,
    I have a requirement as follows:
    Suppose there is a column "A". There many be "n" no. of records for that column "A"
    I want the code logic for this to sum up all the "n"  no. of records,which is of  type amount and to be populated in a single row.
    Ex :
    Column A
    7867.68
    5658.65
    566765.44
    n
    like this "n"  no. of records would be populated (at the runtime).
    I need the output as :
    Column A
    SUM(7867.68 + 5658.65 + 566765.44 + .......n) in a single row.
    Immediate reply would be greatly appreciated.
    Thanks in advance,
    Regards,
    Vamc
    Message was edited by: Manish Kumar : Do not ask for urgent/immediate reply

    Hi vamshi,
    Both Collect and AT END OF.... END AT, we can use for the above requirement.
    Collect Statement:
    LOOP AT IT_TABLE into WA_TABLE.
         COLLECT WA_TABLE TO IT_FINAL.
    ENDLOOP.
    Control Break Statement (AT END OF... END AT):
    If you are using Control break statement, before LOOP Statement, sort the table as shown below.
    "Data Declarations
    DATA: L_END TYPE I VALUE 0,
                L_COUNT TYPE I VALUE 0.
    "Sort the Internal Table
    SORT IT_TABLE BY MATNR.
    LOOP AT IT_TABLE INTO WA_TABLE.
         L_COUNT = L_COUNT + WA_TABLE-VALUE.
         AT END OF MATNR.
              L_END = 1.
         ENDAT.
         IF L_END = 1.
         MOVE CORRESPONDING WA_TABLE to WA_FINAL.
         "Assign Count value
         WA_FINAL-TOTAL  = L_COUNT.
         "Append the value to Internal Table
         APPEND WA_FINAL TO IT_FINAL.
         "Clear WA & Count
         CLEAR: WA_FINAL,
                        L_COUNT,
                        L_END.
         ENDIF.
    ENDLOOP.
    Regards
    Rajkumar Narasimman

  • How to store array of data into a single row of  table ,using any of Stmts

    HI Friends,
    Based on my requirements ,i have retrived a set of data from a XXX.jsp page using a request.getParameter() and stored into single dimenssional array . Now i am paassing that array to JAVA class to store a into some table .
    In JSP page users can add text boxes dynamically based on his intrest then those attributes will store in table .it means table attributes are not conatant , it table attributes may change at any time when user adds any textboxs or any fields on JSP page ....thats my module ..
    Now i wanted to store all array of data into Table in a single row .......thats is my requirements .
    How can we use prepareStatement and Statement to store array of results intoo table row ...on each iteration i wanted to store array of results into table atributes ..It means entire array of results should to into table row at time .....coule any one write sytax ,how we do this...
    could any one suggest me stps that i can impliment ......?....please reply ASAP

    Well ..you code can be works for constant number of attributes in table .oopss here my requirement is table attributes not fixed ,we cant put constant number of place holder(? ) in a statement ,because those are not fixed ,
    Let me explain here :
    i am doing in that way only. As i mentioned you Table attributes are not constant .It may very if users add any fields dynamically on JSP page .If users have option to add any text box on Jsp page ,then that attribute will store in table as a attribute .
    Now i amable fetching the all dyamic form data and stored in a Result Array below ...in this iteration all form result data are from jsp page as suggestion form ,it should stored in table in single row on corrsponding attribtes ......next time when users fills FROM ,then those data i am fetching and storing in a Result Array as below and need to store in corrsponding table attributes in a single row ....
    for(int i=0;i<result.length;i++)
                   System.out.println(result);
                   pst3=connection.prepareStatement("insert into *emprecord* values(?)");
                   if(!result[i].equals(""))
                        System.out.println(result[i]);
                             pst3.setString(1,result[i]);
                             pst3.executeUpdate();
    Thnks in advance ....let me know the the way we can store dynamic form data into dyanamic table ...

  • How to update a single row of data table

    How we can update a single row of the data table by clicking the button in the same row.
    Thanks in Advance.

    Hi!
    What do You mean 'update'? Get fresh data from DB or change data and commit it in DB?
    If commit, try to read here:
    http://developers.sun.com/jscreator/learning/tutorials/2/inserts_updates_deletes.html
    Thanks,
    Roman.

  • How to aggregate a column based date column (for weekly single row)?

    How to aggregate a column based date column (for weekly single row)?

    Hi,
    Consider the below statement for daily bases which is ok
    SELECT ID, DATE, SUM(AMOUNT) FROM TABLE_NAME GROUP BY ID, DATE ORDER BY ID, DATE
    The same like the above statement, I want output on weekly, fortnightly, and monthly bases, How to do this? Need your help...

Maybe you are looking for

  • SharePoint Search encodes the URL incorrectly when there are special characters in a filename on a file share

    In our Sharepoint Server 2013 CA, Search Administration, Content Sources, we have configured a File Share Content Source. Search queryes works fine and it returns relevant documents from the file share content source. But when click on a file with a

  • Looking for a comprehensive online tutorial or book

    Hello Guys! I am looking for a comprehensive online tutorial or book that would contain all steps involving java web application development. For example, it would be cool if it would contain requirement definition, design, implementation, etc. and h

  • Launching Word with exec

    I'm trying to open a file in Microsoft Word and I use: Process m = Runtime.getRuntime().exec("winword.exe \"" + location + "README.doc\""); which reports an exception. Then I try: Process m = Runtime.getRuntime().exec("cmd.exe /c winword.exe \"" + lo

  • How do I open and use Photoshop Elements 12?

    How Do I Open and use Photoshop Elements 12? I've just purchased it and can't find a way to open and use the program. [email protected]

  • ORA-01652 ERROR

    When the Data is loading from DSO --> Info Cube. I'm getting following ERROR message. ERROR Message Error while extracting from source ZOPA_O01 (type InfoProvider) ORA-01652: unable to extend temp segment by 128 in tablespace PSAPTEMP Error reading t