Three records in single row

Hi,
I have three records in table can I put three records in a single row in alv report,
Please suggest,
rewarded highly
thanks in advance
cheers

Hi Ray
Why don't you create an internal table with fields of the tables (lfa1, lfb1 and lfm1) you need to read and display?
A vendor has to have the company data if he used by accounting, if he has only org data, It should mean that vendor is used only as partner.
Anyway every org can belong to only one company code and every vendor can belong to several companies (I don't know your organization) so the output table should be:
DATA: BEGIN OF T_OUTPUT OCCURS 0,
        <LFA1 FIELDS> LIKE LFA1-.....
        <LFB1 FIELDS> LIKE LFB1-.....
        <LFM1 FIELDS> LIKE LFM1-.....
      END   OF T_OUTPUT.
LOOP AT T_LFA1.
  MOVE-CORRESPONDING T_LFA1 TO T_OUTPUT.
You should append one record for every org
  LOOP AT T_LFM1 WHERE LIFNR = T_LFB1-LIFNR.
Check if this org. belong to company vendor
    READ TABLE T_T024E WITH KEY EKORG = T_LFM1-EKORG.
    IF NOT T_T024E-BUKRS IS INITIAL.
      LOOP AT T_LFB1 WHERE LIFR = LFA1-LIFNR.
                       AND BUKRS = T_T024E-BUKRS.
You should append one record for every company
        MOVE-CORRESPONDING T_LFB1 TO T_OUTPUT,
                           T_LFM1 TO T_OUTPUT.
        APPEND T_OUTPUT.
        DELETE: T_LFB1, T_LFM1.
      ENDLOP.
     ENDIF.
  ENDLOOP.
Now you elaborate the org without company:
  LOOP AT T_LFM1 WHERE LIFNR = LFA1-LIFNR.
and here you can elaborate the company with out org:
    LOOP AT T_LFB1 WHERE LIFNR = LFA1-LIFNR.
        MOVE-CORRESPONDING T_LFB1 TO T_OUTPUT,
                           T_LFM1 TO T_OUTPUT.
        APPEND T_OUTPUT.
        DELETE: T_LFB1, T_LFM1.
    ENDLOOP.
and at the end you can elaborate the last vendor
companies:
    LOOP AT T_LFB1 WHERE LIFNR.
      MOVE-CORRESPONDING T_LFB1 TO T_OUTPUT.
    ENDLOOP.
  ENDLOOP. 
Max
Check if org. belong to company
        IF SY-SUBRC = 0.
          MOVE-CORRESPONDING T_LFM1 TO T_OUTPUT.
          APPEND T_LFM1.
          DELETE T_LFM1
        ENDIF.
If vendor haven't company data
  ENDLOOP.
ENDLOOP.
Max

Similar Messages

  • Please help with an sql to show more than one records into single row for each student

    From the following data I would like to create an sql to get the information  as the following layout
    studentid,  firstTerm,  EnglishMark1,ScienceMark1,MathsMark1, Secondterm,EnglishMark2,ScienceMark2,MathsMark2,
    ThirdTerm,EnglishMark3,ScienceMark3,MathsMark3 // As single rows for each student
    Example
    1 First, 30,40,20,Sec,30,40,20,  simillarly next row for next row for another sudent. Please help to generate the sql for the same.
    Please help it would be very appreciate.
    With Thanks
    Pol
    polachan

    create table yourdata (studentid int, term varchar(10), section varchar(50), Mark int)
    insert into yourdata values
    (1,'First','Math',20),(1,'First','English',30),(1,'First','Science',40),
    (2,'First','Math',20),(2,'First','English',30),(2,'First','Science',40),
    (3,'First','Math',20),(3,'First','English',30),(3,'First','Science',40),
    (1,'Sec','Math',20),(1,'Sec','English',30),(1,'Sec','Science',40),
    (2,'Sec','Math',20),(2,'Sec','English',30),(2,'Sec','Science',40),
    (3,'Sec','Math',20),(3,'Sec','English',30),(3,'Sec','Science',40)
    Select studentid
    ,max(case when term='First' and section='English' Then Mark End) as EnglishMark1
    ,max(case when term='First' and section='Science' Then Mark End) as ScienceMark1
    ,max(case when term='First' and section='Math' Then Mark End) as MathMark1
    ,max(case when term='Sec' and section='English' Then Mark End) as EnglishMark2
    ,max(case when term='Sec' and section='Science' Then Mark End) as ScienceMark2
    ,max(case when term='Sec' and section='Math' Then Mark End) as MathMark2
    ,max(case when term='Third' and section='English' Then Mark End) as EnglishMark3
    ,max(case when term='Third' and section='Science' Then Mark End) as ScienceMark3
    ,max(case when term='Third' and section='Math' Then Mark End) as MathMark3
    From yourdata
    Group by studentid
    drop table yourdata

  • How to Disassemble Varying Multiple Repeating Records from Single Row

    I have a flat file that has hundreds of thousands of rows.  Each row is a new record.
    On each row there are about 23 elements that occur once per row and then there are two groups of 4-6 fields each group that repeat a certain number of times.  There is an integer field before each group that indicates how many times the group repeats
    0 or greater.  An few examples rows are the following. 
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|0|0
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|1|b|b|b|b|0
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|2|b|b|b|b|c|c|c|c|0
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|2|b|b|b|b|c|c|c|c|1|d|d|d|d|d|d
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|2|b|b|b|b|c|c|c|c|2|d|d|d|d|d|d|e|e|e|e|e|e
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|0|1|b|b|b|b|b|b
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|0|2|b|b|b|b|b|b|c|c|c|c|c|c
    I'd rather not do a custom pipeline if possible unless there is something already written.
    thanks in advance.

    Thank you for the quick response.  Would rather stick in biztalk if possible.
    I was able to get something like this to process through no problem.
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|1|b|b|b|b
    a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|0
    Just using and unbounded record with the group order type set to sequence. each row could have 0 to hundreds
    of groups.  And I've been able to process files with millions of rows.
    I'm wondering if there is a way to check the integer number in order to tell the group how many records
    there will be?
    Sucks that it is all the same delimiter.

  • Mearge Multiple rows of same record in single row with /

    Dear Friends
    Here I am giving a example, In this example i want to mearge the records containing waybillno 24292 to single record but here i am having seperate tallerno which i want to combine in 1 record with '/'
    Please give the solution urgently
    WAYBILLNO WAYBILLDT TALLERNO TALLERDAT INVOICEVALUE
    24942 31-MAR-11 873000
    24942 31-MAR-11 3142 07-MAR-11
    24942 31-MAR-11 3145 18-MAR-11
    sandy
    Edited by: Sandy on 17 May, 2011 4:57 AM

    /* Formatted on 5/18/2011 10:10:36 AM (QP5 v5.149.1003.31008) */
    WITH t AS (SELECT 24942 WAYBILLNO,
                      '31-MAR-11' WAYBILLDT,
                      873000 TALLERNO,
                      NULL TALLERDAT
                 FROM DUAL
               UNION
               SELECT 24942,
                      '31-MAR-11',
                      3142,
                      '07-MAR-11'
                 FROM DUAL
               UNION
               SELECT 24942,
                      ' 31-MAR-11',
                      3145,
                      '18-MAR-11'
                 FROM DUAL
               UNION
               SELECT 24943,
                      '28-MAR-11',
                      3150,
                      '08-MAR-11'
                 FROM DUAL
               UNION
               SELECT 24943,
                      ' 20-MAR-11',
                      3155,
                      '12-MAR-11'
                 FROM DUAL)
        SELECT WAYBILLNO,
               MAX (SUBSTR (SYS_CONNECT_BY_PATH (WAYBILLDT, ','), 2)) WAYBILLDTS,
               MAX (SUBSTR (SYS_CONNECT_BY_PATH (TALLERNO, ','), 2)) TALLERNOS,
               MAX (SUBSTR (SYS_CONNECT_BY_PATH (TALLERDAT, ','), 2)) TALLERDATS
          FROM (SELECT WAYBILLNO,
                       WAYBILLDT,
                       TALLERNO,
                       TALLERDAT,
                       ROW_NUMBER ()
                       OVER (PARTITION BY WAYBILLNO
                             ORDER BY WAYBILLDT, TALLERNO, TALLERDAT)
                          rn
                  FROM t)
    -- WHERE CONNECT_BY_ISLEAF = 1  don't think connect by isleaf is available in 9i
    -- so you will need to pick the max and group by waybillno
    START WITH rn = 1
    CONNECT BY PRIOR rn = rn - 1 AND PRIOR WAYBILLNO = WAYBILLNO
      GROUP BY WAYBILLNO
      ORDER BY WAYBILLNO
    WAYBILLNO     WAYBILLDTS     TALLERNOS     TALLERDATS
    24942      31-MAR-11,31-MAR-11,31-MAR-11     3145,3142,873000     18-MAR-11,07-MAR-11,
    24943      20-MAR-11,28-MAR-11     3155,3150     12-MAR-11,08-MAR-11

  • To make Three row values in a single row

    Hi,
    Below is the Table Format i have.
    Here for the first Mail_ID i have 3 mail addresses.similarly for second ID too.
    I want First three rows to be in a single row.and so on...
    Plz help in doing this.
    Thanks 
    Deepa

    Deepa,
    Check if this helps.. Does dynamic conersion of data to columns ..
    --Your Email table
    create table #temp (mailid int,to_mail varchar(100))
    insert #temp select 1,'[email protected]'
    insert #temp select 1,'[email protected]'
    insert #temp select 1,'[email protected]'
    insert #temp select 2,'[email protected]'
    insert #temp select 2,'[email protected]'
    insert #temp select 3,'[email protected]'
    --Constructing a temp table to hold data with row_numbers
    select *,row_number() over(partition by mailid order by to_mail) as rn
    into #t
    from #temp
    --declaration of variables
    declare @n int,@list varchar(max),@sql nvarchar(max)
    set @n=(select max(rn) from #t)
    --Population of list to form the dynamic query
    ;with cte
    as
    select cast(',[email1]' as varchar(max)) as ch,1 as num
    UNION ALL
    select cast(ch+',[email'+cast((num+1) as varchar(100))+']' as varchar(max)) as ch,num+1 as num
    from cte where num<@n
    select top 1 @list=stuff(ch,1,1,'')
    from cte
    order by num desc
    --Formulating the complete dynamic query
    set @sql='
    select mailid,'+@list+'
    from
    select mailid,to_mail,''email''+cast(rn as varchar) as emailnum from #t
    ) tab
    PIVOT
    max(to_mail) for emailnum in ('+@list+')
    ) pvt'
    exec sp_executesql @sql
    --clean up
    drop table #t
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • How to merge three columns values to single row values in sql server 2008

    Hi Frds.....
    I have three quantity in my table.
    Quantity1,quantity2,quantity3
    this three quantity have different values
    ex:
    quantity1 = 1000,quantity2=2000,quantity3=3000
    the three column combine 2 display in single row values. this values display in one by one.
    ex: quantity
         1000
         2000
         3000

    You will need to use the UNPIVOT operator:
    DECLARE @example TABLE
    Id int NOT NULL IDENTITY(1,1),
    Quantity1 int,
    Quantity2 int,
    Quantity3 int
    INSERT INTO @example VALUES (1000, 2000, 3000), (4000, 5000, 6000);
    SELECT * FROM @example;
    SELECT Id, Quantity, QuantityType
    FROM @example
    UNPIVOT
    Quantity FOR QuantityType IN (Quantity1, Quantity2, Quantity3)
    ) AS u;
    Output:
    (2 row(s) affected)
    Id Quantity1 Quantity2 Quantity3
    1 1000 2000 3000
    2 4000 5000 6000
    (2 row(s) affected)
    Id Quantity QuantityType
    1 1000 Quantity1
    1 2000 Quantity2
    1 3000 Quantity3
    2 4000 Quantity1
    2 5000 Quantity2
    2 6000 Quantity3
    (6 row(s) affected)

  • How to display the vertical coloumns(records)  in a single row?

    Hi all,
    I need a requirement in SAP where in the internal table records are in vertical placement as follows:
    1 2 3 4 5 | a1 b1 c1 d1 e1
    1 2 3 4 5 | a2 b2 c2 d2 e2
    1 2 3 4 5 | a3 b3 c3 d3 e3
    and so on..........
    now as per the requirement I need all the records to be displayed in a single row in the output as follows:
    1 2 3 4 5 | a1 b1 c1 d1 e1 | a2 b2 c2 d2 e2 | a3 b3 c3 d3 e3 |.....so on
    Any pointers on this would be of great help.
    thanks in advance,
    Vamsee.

    Loop at itab.
    at new f1.
      write : itab-f1.   <--- here don't give '/' .. which will write in new line ...
    endif.
      write : itab-f2,    <--- here don't give '/' .. which will write in new line ...
                itab-f3,
                itab-f4,
                itab-f5,
                itab-f6.
      at end of f1.
         write :/ ''.
      endat.
    endloop.

  • Two rows from a record commig in single row

    Dear All,
    This is the query
    SELECT ROWNUM,TYP,REF_ID , CODE,FRM_DT , FRM_NOTE
    from TABLEA
    where TYP='IQ'
    AND REF_ID ='IQ1107273'
    and (FRM_NOTE LIKE '%AP%' OR FRM_NOTE LIKE '%CL%')
    ORDER BY FRM_DT
    ROWNUM     TYP     REF_ID     CODE FR_DT     FR_NOTE
    1     IQ     IQ01 IR2460 24/07/2011 AP
    2     IQ     IQ01     IR2460 25/07/2011 CL
    3     IQ     IQ02 IR2461 23/07/2011 AP
    4     IQ     IQ02     IR2461 25/07/2011 CL
    could i get this one single row
    ROWNUM TYP REF_ID CODE FR_DT FR_NOTE ROWNUM TYP REF_ID     CODE FR_DT FR_NOTE
    1     IQ IQ01 IR2460 24/07/2011 AP 2     IQ     IQ01     IR2460 25/07/2011 CL
    3     IQ IQ02 IR2461 23/07/2011 AP 4     IQ     IQ02     IR2461 25/07/2011 CL
    -----------------------------------------------------------------------------------------------------------------------------------------------------------

    SQL>WITH t1 AS (SELECT     't1c1_' || ROWNUM AS c1, 't1c2_' || ROWNUM AS c2, ROWNUM AS c3
      2                    FROM DUAL
      3              CONNECT BY LEVEL <= 3),
      4       t2 AS (SELECT     't2c1_' || ROWNUM AS c1, 't2c2_' || ROWNUM AS c2, ROWNUM AS c3
      5                    FROM DUAL
      6              CONNECT BY LEVEL <= 3),
      7       t3 AS (SELECT t1.c1 AS c11, t1.c2 AS c12, t2.c1 AS c21, t2.c2 AS c22, ROWNUM AS r
      8                FROM t1, t2
      9               WHERE t1.c3 = t2.c3)
    10  SELECT   a, b
    11      FROM (SELECT c11 AS a, c21 AS b, r, 1 AS s
    12              FROM t3
    13            UNION ALL
    14            SELECT c12, c22, r, 2 AS s
    15              FROM t3)
    16  ORDER BY r, s;
    A                                             B
    t1c1_1                                        t2c1_1
    t1c2_1                                        t2c2_1
    t1c1_2                                        t2c1_2
    t1c2_2                                        t2c2_2
    t1c1_3                                        t2c1_3
    t1c2_3                                        t2c2_3Urs

  • ALV - Multiple Rows into Single Row

    I have a requirement to display the ALV output from CDHDR&CDPOS tables here in the output i have 15 columns( Fields ) any changes im displaying in report output ,but if there is same time multiple columns will change im displaying as individual record instead of that i need to show as single row.
    in this output last three records have same time change but i have populated into three different columns i want to make it as SINGLE Row Record.
    Thanks!!

    We don't need script task for this. Use TSQL in the datasource. Refer below example
    DECLARE @TEMP TABLE(ID INT, [VALUE] NVARCHAR(30))
    INSERT INTO @TEMP VALUES(1 , 'MAZ')
    INSERT INTO @TEMP VALUES(1 , 'HON')
    INSERT INTO @TEMP VALUES(1 , 'FOR')
    INSERT INTO @TEMP VALUES(2 , 'JEEP')
    INSERT INTO @TEMP VALUES(2 , 'CHE')
    INSERT INTO @TEMP VALUES(3 , 'NIS')
    INSERT INTO @TEMP VALUES(4 , 'GMC')
    INSERT INTO @TEMP VALUES(4 , 'ACC')
    INSERT INTO @TEMP VALUES(4 , 'LEX')
    SELECT [id],
    Stuff((SELECT ',' + [VALUE]
    FROM @TEMP
    WHERE [id] = a.[id]
    FOR xml path('')), 1, 1, '') [VALUE]
    FROM @TEMP a
    GROUP BY [id]
    Regards, RSingh

  • PL/SQL muliple row insert for a single row

    I need to insert multiple rows based on a single row record. Below are the table structures and sample data
    CREATE TABLE TEST_SAMPLE (NAME VARCHAR2(20), ATTR_1 VARCHAR2(20), ATTR_2 VARCHAR2(20), ATTR_3 VARCHAR2(20),ATTR_4 VARCHAR2(20));
    CREATE TABLE TRANSACTION (NAME VARCHAR2(20), ATTR VARCHAR2(20))
    insert into TEST_SAMPLE (NAME, ATTR_1, ATTR_2, ATTR_3,ATTR_4) values ('hello','asd','fgh','ert',null);For the above record in table TEST_SAMPLE, three records have to be populated\inserted into table TRANSACTION. In PL/SQL
    stored procedure i am inserting records to TRANSACTION when ATTR_1 or ATTR_2 or ATTR_3 or ATTR_4 is not null.
    Please help me to find a better way for the above insert to table TRANSACTION?

    Thanks for helping me here. For the sample record in table TEST_SAMPLE i mentioned above three records need to be inserted in table TRANSACTION. you have this, or?
    CREATE TABLE TEST_SAMPLE (NAME VARCHAR2(20), ATTR_1 VARCHAR2(20), ATTR_2 VARCHAR2(20), ATTR_3 VARCHAR2(20),ATTR_4 VARCHAR2(20));
    CREATE TABLE TEST_TRANSACTION (NAME VARCHAR2(20), ATTR VARCHAR2(20));
    insert into TEST_SAMPLE (NAME, ATTR_1, ATTR_2, ATTR_3,ATTR_4) values ('record 1','asd','fgh','ert',null);
    insert into TEST_SAMPLE (NAME, ATTR_1, ATTR_2, ATTR_3,ATTR_4) values ('record 2',null,'fgh','ert',null);
    insert into TEST_SAMPLE (NAME, ATTR_1, ATTR_2, ATTR_3,ATTR_4) values ('record 3','asd',null,'ert',null);
    insert into TEST_SAMPLE (NAME, ATTR_1, ATTR_2, ATTR_3,ATTR_4) values ('record 4','asd','fgh',null,null);
    insert into TEST_SAMPLE (NAME, ATTR_1, ATTR_2, ATTR_3,ATTR_4) values ('record 5','asd',null,null,null);
    insert into TEST_SAMPLE (NAME, ATTR_1, ATTR_2, ATTR_3,ATTR_4) values ('record 6',null,null,null,null);
    commit;
    insert into TEST_TRANSACTION
    select NAME,
            ATTR_1
    from TEST_SAMPLE
    where ATTR_1 is not null
    union all
    select NAME,
            ATTR_2
    from TEST_SAMPLE
    where ATTR_2 is not null
    union all
    select NAME,
            ATTR_3
    from TEST_SAMPLE
    where ATTR_3 is not null
    union all
    select NAME,
            ATTR_4
    from TEST_SAMPLE
    where ATTR_4 is not null
    commit;
    select *
    from TEST_TRANSACTION
    order by 1;
    Table created.
    Table created.
    1 row created.
    1 row created.
    1 row created.
    1 row created.
    1 row created.
    1 row created.
    Commit complete.
    10 rows created.
    Commit complete.
    NAME                 ATTR               
    record 1             asd                
    record 1             fgh                
    record 1             ert                
    record 2             fgh                
    record 2             ert                
    record 3             ert                
    record 3             asd                
    record 4             fgh                
    record 4             asd                
    record 5             asd                
    10 rows selected.

  • Single row in alv report

    Hi experts...
    I want single row in alv report.
    I have use loop for fatch data into internal table using loop when i am passing data in alv report then the data comes according loop. i want onlu one data in alv row.
    how can i do such, plz help me.

    decleare two internal table.
    read table itab into  wa index  1.
    append wa to itab2.
    pass itab2 only one record display.

  • 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

  • Interactive Report Single Row View Error

    I am getting the following error on my Single Row View
    {"dialog":{"uv":true,"row":[{"V":"Widget Failure
    ORA-20001: SHOW error. ORA-20001: VIEW_ROW error. ORA-20001: GET_COLUMN_VALUE error. ORA-01722: invalid number,
    worksheet"}]}}Any clues?
    Shunt

    Shunt,
    Does this happen on every record? Have you tried to recreate the IRR on another page as a test? Do a SELECT * FROM table...
    Regards,
    Dan
    http://danielmcghan.us
    http://sourceforge.net/projects/tapigen
    http://sourceforge.net/projects/plrecur
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • Multiple pages that edit a single row

    I have searched on tabs and editing a single row using multiple pages and I am confused. I don't want to use java as I am trying to not learn that too...
    What I am trying to do sounds like it has been explained before but let me do this again...
    I have a record that is too large to fit on a single screen. This makes for a cumbersome entry process. The record is actually broken into four "logical" chunks. Main, Sub1, Sub2 and Sub3.
    I have made a list that will allow the record to be selected and call the first logical page... L1.
    I have made tabs that show all the pages and allow me to navigate between them quickly.
    When I get to L1 all the data is there. I may not change any data on that page and go directly to L2 through L4. However the record is not brought forward onto those pages. So the pages are not related (and I don't have the terminology right I know :) and I could "link" the pages. So here is what I would like the application to do;
    1. Display a list and allow the user to select the record to edit.
    2. Upon edit go to the first page (tab).. this works
    3. Allow the user to select a tab and the page displays the data for the record selected
    4. Allow the user to complete the edits and save the record. Upon save the user is returned to the list in step 1.
    I was thinking there are several ways to do it... but I was hoping someone could save me a bunch of trial and error (emphasis on the error) ...
    1. When navigating off the page save the record, pass the key and re-read the record... ugly huh?
    2. Pass all the session data for the record over to the next screen. Is that possible? e.g pxx_field1 = pyy_field1
    The the question was does a template with two level tabs keep the record data between tabs?
    Any help is greatly appreciated.
    Sam

    I think this works... kinda
    1. I have a "list" that allows the selection of the item to edit.
    2. That list opens a page that is the "header" page for a tab set.
    3. Each page in the tab set uses the same "ID" to read the record and display the columns. That is how it would work if the list called each individual page.
    4. I modified the "slave" tabs to have the "ID" of the "header" page.
    This displays the correct data on each page. And it looks like the "apply changes" button saves the changes on the page.
    Caveats inlclude (I think as I haven't done exhaustive testing"
    1. "apply changes" must be done at each page where there were changes or they would be lost.
    2. The first dispaly of the page is blank. Clicking on the tab a second time displays the data. This is true if it is the first time a user selects a record in a session (the "slave" tabs are blank) or if it is a subsequent record update (the "slave" tabs have the last records data.
    Thoughts... is this really boring to everyone but me?
    Sam

Maybe you are looking for

  • Can't save my documents!

    When I click "save" or "save as", Appleworks freezes and I have to force quit just to get back to my document. Any help? Thanks, Teri

  • ANY SPEAKERS WITHOUT FLIGHT MODE?

    I was thinking about getting the Harman Kardon Go+Play Boombox for iPod but I don't want to put my phone in flight mode. Now that the Iphone has the video out function does anyone know if I can dock my phone in these speakers and use the video out fu

  • Chart Properties on IR Reports

    We are dynamically adding measure values to X and Y axes of a scatter chart. This happens on the ON Process button in the dashboard. Say the X axis was X_Sales measure value and the Y axis was Y_Sales value the first time. Hitting the process button

  • Drawing in captivate 7

    Hi, I am building a program to teach physics.  I was wondering if there was a way for my viewers to draw on a graph as part of a quiz.  We were going to do something like the drag and drop interactive but decided it would be much nicer for them to ju

  • Determine Users in a Role

    Hello, From SQLPlus how can you determine what users are in a Role? Thanks, Michael