Query for Finding the Date History

Hi Geeks,
My Table looks like this
Employee Assignment Position     Job     Grade     Start_date     End_date
101 132 2055 Clerk C01 10-Mar-00 11-Feb-01
101 132 2055 Clerk C02 12-Feb-01 15-Dec-01
101 132 2056 Clerk C02 16-Dec-01 22-Jul-03
101 132 2055 Clerk C03 23-Jul-03 31-Dec-4000 --(unassigned)
Now I need output like
Employee Assignment Position Start_date End_date
101 132 2055 10-Mar-2000 15-Dec-2001
101 132 2056 16-Dec-2001 22-Jul-2003
101 132 2055 23-Jul-2003 31-Dec-4000 --(unassigned)
The following important things are to be considered
1. Rows to be grouped by position
2. Each row much have the start date and end date of the employee position. If the employee is the same postion and different grade or job that doesnt matter. But if the employee jumps from his position (2055) to 2056 and after sometime he comes to the same position (i.e. 2055) the date history should be separate.
I am unable to derive the logic also. I think we need to create a function for this.
Kindly help me out.
Thanks in Advance
Punithavel
Message was edited by:
Punithavel
Message was edited by:
Punithavel

Too difficult to read. I have no database access to test (usually I use a step by step approach, proceeding with the next step when the current one is OK).
I can describe a general idea (may post something afterwards with no promise it will work)
step 1: mark the position changes
step 2: retain only mark 1 and mark max(mark) of each group
step 3: make a single row from the two rows of each group
Regards
Etbin
with
marking as
(select employee,assignment,position,start_date,end_date,
        row_number() over (partition by employee,assignment,position order by start_date) the_mark
   from the_table
collecting as
(select employee,assignment,position,start_date,end_date,the_mark
   from marking m
  where the_mark = 1
     or the_mark = (select max(the_mark)
                      from marking
                     where employee = m.employee
                       and assignment = m.assignment
                       and position = m.position
                     group by employee,assignment,position
                     having count(*) > 1
combining as
(select employee,assignment,position,
        case when the_mark = 1 then start_date end start_date,
        case when the_mark = 1
             then case when lead(position,1) over (partition by employee,assignment,position order by start_date) = position
                       then lead(end_date,1) over (partition by employee,assignment,position order by start_date)
                       else end_date
                  end
        end end_date
   from collecting
select employee,assignment,position,start_date,end_date
  from combining
where start_date is not null
order by employee,assignment,position,start_date*** not tested ***
Message was edited by: Etbin
user596003
on a lazy afternoon I took a look at your friend's solution too and I like it.
It's more concise than mine (defining starts and ends).
Not being able to test it the only problem in his solution might be the absence of order by clauses to assign correct rownums
WITH lag_and_lead AS
(SELECT employee,assignment,position,start_date,end_date,
        LAG (position) OVER (PARTITION BY employee,assignment ORDER BY start_date) AS lag_position,
        LEAD (position) OVER (PARTITION BY employee,assignment ORDER BY start_date) AS lead_position
   FROM your_table
  ORDER BY employee,assignment,start_date
starts AS
(SELECT employee,assignment,position,start_date,ROWNUM rn
   FROM lag_and_lead
  WHERE position <> lag_position
     OR lag_position IS NULL
  order by employee,assignment,start_date
ends AS
(SELECT employee,assignment,position,end_date,ROWNUM rn
   FROM lag_and_lead
  WHERE position <> lead_position
     OR lead_position IS NULL
  order by employee,assignment,start_date
SELECT starts.employee,starts.assignment,starts.position,starts.start_date,ends.end_date
  FROM starts,ends
WHERE starts.employee = ends.employee
   AND starts.assignment = ends.assignment
   AND starts.position = ends.position
   AND starts.rn = ends.rn
EMPLOYEE ASSIGNMENT POSITION JOB   GRADE START_DATE  END_DATE
     101        132     2055 Clerk C01   10-Mar-2000 11-Feb-2001
     101        132     2055 Clerk C02   12-Feb-2001 15-Dec-2001
     101        132     2056 Clerk C02   16-Dec-2001 22-Jul-2003
     101        132     2055 Clerk C03   23-Jul-2003 31-Dec-4000
lag_and_lead
EMPLOYEE ASSIGNMENT POSITION START_DATE  END_DATE    lag_position lead_position
     101        132     2055 10-Mar-2000 11-Feb-2001         null          2055
     101        132     2055 12-Feb-2001 15-Dec-2001         2055          2056
     101        132     2056 16-Dec-2001 22-Jul-2003         2055          2055
     101        132     2055 23-Jul-2003 31-Dec-4000         2056          null
starts
EMPLOYEE ASSIGNMENT POSITION START_DATE  rn
     101        132     2055 10-Mar-2000  1
     101        132     2056 16-Dec-2001  2
     101        132     2055 23-Jul-2003  3
ends
EMPLOYEE ASSIGNMENT POSITION END_DATE    rn
     101        132     2055 15-Dec-2001  1
     101        132     2056 22-Jul-2003  2
     101        132     2055 31-Dec-4000  3
EMPLOYEE ASSIGNMENT POSITION START_DATE  END_DATE
     101        132     2055 10-Mar-2000 15-Dec-2001
     101        132     2056 16-Dec-2001 22-Jul-2003
     101        132     2055 23-Jul-2003 31-Dec-4000Regards
Etbin
Message was edited by: Etbin
user596003

Similar Messages

  • Query for Finding the Daily Cumulative Production Total

    Hi Experts,
    I want Query based Report for finding Daily Cumulative i.e Running Production Total
    Suppose Yesterdays Production for Item A0001 is 20 and Todays Prodction is 20 then it will show 50 but it shout be datewise selection.
    Warm Regards,
    Sandip Kokate

    Hello
    Report Scenario as follow
    Item Code    Item name    Todays Producion     Yesterdays Production   Total Productio
    A001           Computer     20                                    20                                  40
    A002           Mouse          10                                    05                                  15
    A003           CPU              15                                    05                                  20
    This is Exact Report
    Regards,
    Sandip Kokate

  • Query for extracting the data in tags

    I have data in table like
    col1 col2
    1 Appli<resourceId>Page_Attorny</resourceId>
    How I will get output of query as
    Page_Attorny
    Plz help.
    Thanx in advance.

    Hi,
    I hope you are looking some thing like :
    SQL>create table XMLTable (col1 number, col2 XMLType);
    Table created.
    SQL>insert into XMLTable values (1,XMLType('<resourceId>Page_Attorny</resourceId>'));
    1 row created.
    SQL>SELECT col1, extractValue(col2,'resourceId') FROM XMLTable;
          COL1
    EXTRACTVALUE(COL2,'RESOURCEID')
             1
    Page_Attorny
    1 row selected.
    SQL>Regards

  • Query to find the latest record with respect to the current status

    Dear gurus
    I have the following data in a table
    Customernum
    bkcode
    reqtdate
    Prevstat
    currstat
    The data will be like this
    CustomerNum bkcode reqdate prevstat currstat
    5900 1 03-Aug-12 0 1
    5900 1 06-Aug-12 1 0
    5900 5 22-Jun-12 0 1
    If a customer has an issue to solved, a record is added with bkcode , register date and currstat will be 1
    If the issue is resolved for the bookingcode,a new record is added, the currentstatus will become 0. and prev stat will show 1. Row no 1 and 2 reflects this case
    If this table is queried for finding the unresolved issues. the output should be only the Last row of the above example. since issue with bookingcode 1 has been resolved
    I have trying hard to get this thing confused what to use Lead or Max
    Kindly guide me

    Hi,
    one way here:
    WITH mytable(CustomerNum, bkcode, reqdate, prevstat, currstat)
    AS
       SELECT 5900, 1, TO_DATE('03-Aug-12', 'DD-Mon-YY'), 0, 1 FROM DUAL UNION ALL
       SELECT 5900, 1, TO_DATE('06-Aug-12', 'DD-Mon-YY'), 1, 0 FROM DUAL UNION ALL
       SELECT 5900, 5, TO_DATE('22-Jun-12', 'DD-Mon-YY'), 0, 1 FROM DUAL
    SELECT CustomerNum, bkcode, reqdate, prevstat, currstat
      FROM (SELECT a.*
                 , ROW_NUMBER() OVER (PARTITION BY CustomerNum, bkcode
                                           ORDER BY reqdate DESC) AS rn
              FROM mytable a
    WHERE rn=1
       AND currstat=1;
    CUSTOMERNUM     BKCODE REQDATE     PREVSTAT   CURRSTAT
           5900          5 22-JUN-12          0          1Regards.
    Al
    Edited by: Alberto Faenza on Dec 18, 2012 5:23 PM
    Changed again!! Previous logic was wrong

  • Write a query for finding STDDEV for OLAP Cube

    Can anybody post a sample query which will find the standard deviation of sales for each month in the sample GLOBAL OLAP schema for Oracle 11g.
    The OLAP option automatically generates a set of relational views on cubes, dimensions, and hierarchies in Oracle 11g. So how can i write a query for finding the Standard deviation on these views.

    The easiest way to do this is to do this directly within the AW using a custom calculated measure. In AWM11g you can use the 11g custom measure wrapper to execute the STDDEV function:
    olap_dml_expression('function',data type)
    For example
    olap_dml_expression('STDDEV(cube_name, time_dimension_name)',number)
    You can then simply expose this calculated measure as another column in your SQL View and then there is no need to use the SQL equivalent. This means the calculation is performed inside the AW (which is as close to the source data as you can get) ensuring performance of the whole query remains high.
    If necessary you can take this a step further, if required, and wrap the STDDEV calculation within an OLAP DML program that would allow you to manipulate the status of time within the calculation. For example, you may want the STDDEV calc to only take into account the last 12 time periods rather than all time periods currently in status.
    Hope this helps
    Keith Laker
    Oracle EMEA Consulting
    OLAP Blog: http://oracleOLAP.blogspot.com/
    OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
    DM Blog: http://oracledmt.blogspot.com/
    OWB Blog : http://blogs.oracle.com/warehousebuilder/
    OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
    DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html

  • Need a query for export table data .....

    Hi,
    I need a query for exporting the data in a table to a file.
    Can anyone help me ?
    Thanking You
    Jeneesh

    SQL> spool dept.txt
    SQL> select * from dept;
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> spool off
    SQL> ed dept.txt

  • Query taking long time for EXTRACTING the data more than 24 hours

    Hi ,
    Query taking long time for EXTRACTING the data more than 24 hours please find the query and explain plan details below even indexes avilable on table's goe's to FULL TABLE SCAN. please suggest me.......
    SQL> explain plan for select a.account_id,round(a.account_balance,2) account_balance,
    2 nvl(ah.invoice_id,ah.adjustment_id) transaction_id,
    to_char(ah.effective_start_date,'DD-MON-YYYY') transaction_date,
    to_char(nvl(i.payment_due_date,
    to_date('30-12-9999','dd-mm-yyyy')),'DD-MON-YYYY')
    due_date, ah.current_balance-ah.previous_balance amount,
    decode(ah.invoice_id,null,'A','I') transaction_type
    3 4 5 6 7 8 from account a,account_history ah,invoice i_+
    where a.account_id=ah.account_id
    and a.account_type_id=1000002
    and round(a.account_balance,2) > 0
    and (ah.invoice_id is not null or ah.adjustment_id is not null)
    and ah.CURRENT_BALANCE > ah.previous_balance
    and ah.invoice_id=i.invoice_id(+)
    AND a.account_balance > 0
    order by a.account_id,ah.effective_start_date desc; 9 10 11 12 13 14 15 16
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)|
    | 0 | SELECT STATEMENT | | 544K| 30M| | 693K (20)|
    | 1 | SORT ORDER BY | | 544K| 30M| 75M| 693K (20)|
    |* 2 | HASH JOIN | | 544K| 30M| | 689K (20)|
    |* 3 | TABLE ACCESS FULL | ACCOUNT | 20080 | 294K| | 6220 (18)|
    |* 4 | HASH JOIN OUTER | | 131M| 5532M| 5155M| 678K (20)|
    |* 5 | TABLE ACCESS FULL| ACCOUNT_HISTORY | 131M| 3646M| | 197K (25)|
    | 6 | TABLE ACCESS FULL| INVOICE | 262M| 3758M| | 306K (18)|
    Predicate Information (identified by operation id):
    2 - access("A"."ACCOUNT_ID"="AH"."ACCOUNT_ID")
    3 - filter("A"."ACCOUNT_TYPE_ID"=1000002 AND "A"."ACCOUNT_BALANCE">0 AND
    ROUND("A"."ACCOUNT_BALANCE",2)>0)
    4 - access("AH"."INVOICE_ID"="I"."INVOICE_ID"(+))
    5 - filter("AH"."CURRENT_BALANCE">"AH"."PREVIOUS_BALANCE" AND ("AH"."INVOICE_ID"
    IS NOT NULL OR "AH"."ADJUSTMENT_ID" IS NOT NULL))
    22 rows selected.
    Index Details:+_
    SQL> select INDEX_OWNER,INDEX_NAME,COLUMN_NAME,TABLE_NAME from dba_ind_columns where
    2 table_name in ('INVOICE','ACCOUNT','ACCOUNT_HISTORY') order by 4;
    INDEX_OWNER INDEX_NAME COLUMN_NAME TABLE_NAME
    OPS$SVM_SRV4 P_ACCOUNT ACCOUNT_ID ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT_NAME ACCOUNT_NAME ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT CUSTOMER_NODE_ID ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT ACCOUNT_TYPE_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_ACCOUNT_TYPE ACCOUNT_TYPE_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_INVOICE INVOICE_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_PREVIOUS_INVOICE PREVIOUS_INVOICE_ID ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_NAME ACCOUNT
    OPS$SVM_SRV4 U_ACCOUNT_NAME_ID ACCOUNT_ID ACCOUNT
    OPS$SVM_SRV4 I_LAST_MODIFIED_ACCOUNT LAST_MODIFIED ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_INVOICE_ACCOUNT INVOICE_ACCOUNT_ID ACCOUNT
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT ACCOUNT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ACCOUNT SEQNR ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_INVOICE INVOICE_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV INVOICE_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA CURRENT_BALANCE ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA INVOICE_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ADJUSTMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_CIA ACCOUNT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_LMOD LAST_MODIFIED ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADINV ADJUSTMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_PAYMENT PAYMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_ADJUSTMENT ADJUSTMENT_ID ACCOUNT_HISTORY
    OPS$SVM_SRV4 I_ACCOUNT_HISTORY_APPLIED_DT APPLIED_DATE ACCOUNT_HISTORY
    OPS$SVM_SRV4 P_INVOICE INVOICE_ID INVOICE
    OPS$SVM_SRV4 U_INVOICE CUSTOMER_INVOICE_STR INVOICE
    OPS$SVM_SRV4 I_LAST_MODIFIED_INVOICE LAST_MODIFIED INVOICE
    OPS$SVM_SRV4 U_INVOICE_ACCOUNT ACCOUNT_ID INVOICE
    OPS$SVM_SRV4 U_INVOICE_ACCOUNT BILL_RUN_ID INVOICE
    OPS$SVM_SRV4 I_INVOICE_BILL_RUN BILL_RUN_ID INVOICE
    OPS$SVM_SRV4 I_INVOICE_INVOICE_TYPE INVOICE_TYPE_ID INVOICE
    OPS$SVM_SRV4 I_INVOICE_CUSTOMER_NODE CUSTOMER_NODE_ID INVOICE
    32 rows selected.
    Regards,
    Bathula
    Oracle-DBA

    I have some suggestions. But first, you realize that you have some redundant indexes, right? You have an index on account(account_name) and also account(account_name, account_id), and also account_history(invoice_id) and account_history(invoice_id, adjustment_id). No matter, I will suggest some new composite indexes.
    Also, you do not need two lines for these conditions:
    and round(a.account_balance, 2) > 0
    AND a.account_balance > 0
    You can just use: and a.account_balance >= 0.005
    So the formatted query isselect a.account_id,
           round(a.account_balance, 2) account_balance,
           nvl(ah.invoice_id, ah.adjustment_id) transaction_id,
           to_char(ah.effective_start_date, 'DD-MON-YYYY') transaction_date,
           to_char(nvl(i.payment_due_date, to_date('30-12-9999', 'dd-mm-yyyy')),
                   'DD-MON-YYYY') due_date,
           ah.current_balance - ah.previous_balance amount,
           decode(ah.invoice_id, null, 'A', 'I') transaction_type
      from account a, account_history ah, invoice i
    where a.account_id = ah.account_id
       and a.account_type_id = 1000002
       and (ah.invoice_id is not null or ah.adjustment_id is not null)
       and ah.CURRENT_BALANCE > ah.previous_balance
       and ah.invoice_id = i.invoice_id(+)
       AND a.account_balance >= .005
    order by a.account_id, ah.effective_start_date desc;You will probably want to select:
    1. From ACCOUNT first (your smaller table), for which you supply a literal on account_type_id. That should limit the accounts retrieved from ACCOUNT_HISTORY
    2. From ACCOUNT_HISTORY. We want to limit the records as much as possible on this table because of the outer join.
    3. INVOICE we want to access last because it seems to be least restricted, it is the biggest, and it has the outer join condition so it will manufacture rows to match as many rows as come back from account_history.
    Try the query above after creating the following composite indexes. The order of the columns is important:create index account_composite_i on account(account_type_id, account_balance, account_id);
    create index acct_history_comp_i on account_history(account_id, invoice_id, adjustment_id, current_balance, previous_balance, effective_start_date);
    create index invoice_composite_i on invoice(invoice_id, payment_due_date);All the columns used in the where clause will be indexed, in a logical order suited to the needs of the query. Plus each selected column is indexed as well so that we should not need to touch the tables at all to satisfy the query.
    Try the query after creating these indexes.
    A final suggestion is to try larger sort and hash area sizes and a manual workarea policy.alter session set workarea_size_policy = manual;
    alter session set sort_area_size = 2147483647;
    alter session set hash_area_size = 2147483647;

  • HT1414 how can i find the dates of the latest backup for iphone and ipad

    i cannot seem to find the dates of last  backup for my iphone or ipad..
    what buttons will lead me to the answer

    iTunes or iCloud?
    iTunes - in preferences > devices
    iCloud - from each device Settings > iCloud > Storage & Backup. The date last backed up will be below the Backup Now button.

  • Query For Finding Yearly Opening and Closing Balance for All the Items

    Hi Experts,
    I am working on Query Based Report for finding the Yearly Opening and Closing Stock for all the Items
    i will give yearwise selection and I want opening and closing stock in between that years
    Warm Regards,
    Sandip Kokate
    Edited by: Sandipk on May 20, 2011 1:58 PM

    Hi,
    Declare @SDate DateTime
    Declare @EDate DateTime
    Declare @Whse nvarchar(10)
    Set @SDate= (SELECT min(F_RefDate)  FROM  OFPR T1 where  T1.[Name] ='[1%]' )
    Set @EDate= (SELECT max(T_RefDate)  FROM  OFPR T1 where  T1.[Name] ='[%1]' )
    Set @Whse=(Select Max(s2.Warehouse) from OINM S2 Where S2.Warehouse = '[%2]')
    BEGIN
    Select @Whse as 'Warehouse', a.Itemcode, max(a.Dscription) as ItemName,
    sum(a.OpeningBalance) as OpeningBalance, sum(a.INq) as 'IN', sum(a.OUT) as OUT,
    ((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT)) as Closing ,
    (Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM
    from( Select N1.Warehouse, N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))
    as OpeningBalance, 0 as INq, 0 as OUT From dbo.OINM N1
    Where N1.DocDate < @SDate and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,
    N1.Dscription Union All select N1.Warehouse, N1.Itemcode, N1.Dscription, 0 as OpeningBalance,
    sum(N1.inqty) , 0 as OUT From dbo.OINM N1 Where N1.DocDate >= @SDate and N1.DocDate <= @EDate
    and N1.Inqty >0 and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription
    Union All select N1.Warehouse, N1.Itemcode, N1.Dscription, 0 as OpeningBalance, 0 , sum(N1.outqty) as OUT
    From dbo.OINM N1 Where N1.DocDate >= @SDate and N1.DocDate <=@EDate and N1.OutQty > 0
    and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription) a, dbo.OITM I1
    where a.ItemCode=I1.ItemCode
    Group By a.Itemcode Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0 Order By a.Itemcode
    END
    I hope this will work for you.
    In above query you can also user OFPR.Code, OFPR, Category OFPR.Indicator instead of OFPR.Name.
    Regards
    Vaibhav Anharwadkar
    Edited by: Vaibhav Ancharwadkar on May 24, 2011 9:23 AM

  • Query to find the  second maximum date in a table

    please give me the query to find the second maximum date in a table

    You can try with this
    SELECT empno
          ,hiredate
      FROM emp        a
    WHERE 2          = (SELECT COUNT(DISTINCT hiredate)
                           FROM emp        b
                          WHERE b.hiredate      >= a.hiredate
    OR
    SELECT empno
          ,hiredate
      FROM (SELECT ROWNUM      row_num
                  ,empno
                  ,hiredate
              FROM emp        a
          ORDER BY hiredate   ASC
    WHERE row_num             = 2;Regards
    Arun

  • Sql query to find the balances for a customer account wise.

    Hi,
    Could someone help me with the sql query to find the balances for each customer account wise. This is need to generate the report.
    presently we are using this query, but the output doesnot return the expected result.
    SELECT sum(nvl(ps.acctd_amount_due_remaining,0)) "Balance"
    FROM      ra_cust_trx_line_gl_dist_all gld,
              gl_code_combinations c,
              ar_payment_schedules_all ps,
              RA_CUSTOMER_TRX_ALL rat,
              ra_customers rc
    WHERE      c.CHART_OF_ACCOUNTS_ID = 101
    and gld.code_combination_id = c.code_combination_id
         and rat.CUSTOMER_TRX_ID=gld.CUSTOMER_TRX_ID
         and rat.CUSTOMER_TRX_ID=ps.CUSTOMER_TRX_ID
    and ps.customer_id=rc.customer_id
         and ps.status='OP'
         and ps.gl_date <= :PDATE
         and ps.org_id=:PORGID
         and ps.class in ('GUAR','INV','DM','DEP')
    and c.SEGMENT4=:Account_id
    and ps.customer_id=:Customer_id
    Thanks in advance.
    Kalyan.

    Can someone help us with this.

  • SQL query for making the horizontally stored data to vertical format

    HI i have a table named table1 and columns and data as below like below
    table1
    Main sub1 sub2 sub3 sub4 sub5 sub6
    A L1 T1
    B L1 T1
    C L2 T2 K1 T1
    D L2 T2 K1 T1
    Basically the data is stored in horizontal above.i want a query to make the data in vertical like below
    A T1
    A L1
    B T1
    B L1
    C T1
    C K1
    C T2
    C L2
    D T1
    D K1
    D T2
    D L2
    Aslo even if the values come in sub5 and sub6 the query should handle and populate the values vertically and also if a new row added also.
    Thanks a lot in advance

    Hi,
    As usual, Hoek is absolutely correct.
    There are a gazillion examples out there, but someone (I) will give you a specific answer.
    Search for "pivot" or "rows to columns" and you will indeed get a gazillion hits. Unfortunately, all but a hemi-semi-demi-gazillion of them will say "There are already lots of examples out there: do a search". Perhaps [this one|http://forums.oracle.com/forums/message.jspa?messageID=3227388#3227388] can get you started.
    The essential form of a pivot is:
    SELECT       r_val
    ,       MIN (CASE WHEN c_val = 1 THEN d END)     AS col_1
    ,       MIN (CASE WHEN c_val = 2 THEN d END)     AS col_2
    ,       MIN (CASE WHEN c_val = n THEN d END)     AS col_n
    FROM       table_x
    GROUP BY  r_val;Instead of MIN (which is probably what want) any aggregate function can be used.
    This assumes you have a column r_val that indicates what row of output will contain each value. In your example, that's your first column,
    It also assumes you have a column c_val that indicates what column will contain each value. In your example, what is that? Looking at the raw data, how can you tell that 'L2' will wind up in the 2nd column of 'D L2 T2 K1 T1', and not the 3rd, 4th or 5th? You may need to assign a c_val to each row (using the aggregate ROW_NUMBER function, perhaps).

  • If the data network is not available for some time, to get it again we need to restart the phone instead it is not finding the data network instantly. why cant the iphone searches data net work offten if not available. i am totally disappointed with this!

    If the data network is not available for some time, to get it again we need to restart the phone instead it is not finding the data network instantly. why cant the iphone searches data net work offten if not available. i am totally disappointed with this!

    Still it could not find the data network.it searches for voice network instantly and works too. but even full voice network available, there is no data network.when i restart the phone it could find data network.
    Already i reset network settings for two times.

  • How to find the data flow for a given module.

    Hi ,
    Is there a way to find the data flow for a given module(Example AR,AP,......).
    I mean are there any predefined document other than user guides that explains with data flow diagrams(including the tables involved).
    Any help would be greatly appreciated.
    Thanks & Regards,
    Naveen.

    No such public document available from Oracle unless from Oracle Education.
    for some specific operation you can check Process tab inside Oracle Application which shows the data flow as part for workflow process.
    Regards
    Prashant Pathak

  • Is there is any way to find the data transfer from client to Configuration Manager for health monitoring and hardware Inventory

    Hi
    Can Configuration Manager provide a way to find the data transfer from client to Configuration Manager for health monitoring and hardware Inventory. How can I know what amount of data is consumed during that process

    Place archive_reports.sms in %systemroot%\ccm\inventory\temp\ for both 64-bit and 32-bit computers.
    There are two situations where you can use this depending on the type of client:
    1. To keep inventory reports on a client (that is not an MP), create the following file:
    %systemroot%\ccm\inventory\temp\archive_reports.sms
    2. To keep inventory reports on a MP (that is also a client), create the following file:
    <x>:\sms_ccm\inventory\temp\archive_reports.sms
    The XML file will be saved in the inventory\temp folder.
    More information on the above here: http://blogs.technet.com/b/configurationmgr/archive/2012/09/17/controlling-configuration-manager-2012-using-hidden-files.aspx

Maybe you are looking for

  • Problem with SolMan installation on linux

    Hi, I am planning to install SAP Solution Manager in SUSE Linux 11.1 version. I have installed Linux and installed JDK 1.4.2_19 version and have set the JAVA_HOME and PATH environment variables. Now when i try to execute ./sapinst from IM<OS> folder

  • Error in Transformation BI 7.0

    Hi I'm getting an error in the transformation of one of the key figures that I have in my Infocube. Rule5 (target PRC_MAT, group: Standard Group): Conversion Type Missing Rule5_target field: PRC_MAT): Field PERUNITSALESPRICE must be assigned to an In

  • How do you get your songs from your ipod to your computer?

    can anyone tell me how to get your songs from your ipod to your computer?

  • Reporting tools in java

    hi gurus, can anyone please tell me some reporting tools in java. where i can embed MS Excel . Our's is swing application thanks in advance , kiran

  • Can I delete duplicates globally in ITunes?

    Can I globally delete duplicates in my ITunes library?