Generate column value based on conditions

BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE     11.2.0.3.0     Production
TNS for HPUX: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Productionselect statement to generate input
WITH t
     AS (    SELECT 1 job_request_id,
                    1 original_job_request_id,
                    mod(level,3) +1  sequence_cd,
                    CHR (LEVEL + 100) value_txt,
                    NULL new_sequence_cd
               FROM DUAL
         CONNECT BY LEVEL < 6),
     t1
     AS (    SELECT 2 job_request_id,
                    1 original_job_request_id,
                    mod(LEVEL,2) + 1 sequence_cd,
                    CHR (LEVEL + 110) value_txt,
                    NULL
               FROM DUAL
         CONNECT BY LEVEL < 10),
     t2
     AS (    SELECT 3 job_request_id,
                    3 original_job_request_id,
                    mod(LEVEL,3) + 7 sequence_cd,
                    CHR (LEVEL + 95) value_txt,
                    NULL
               FROM DUAL
         CONNECT BY LEVEL < 9),
     t3
     AS (    SELECT 4 job_request_id,
                    3 original_job_request_id,
                    mod(LEVEL,2) + 1 sequence_cd,
                    CHR (LEVEL + 95) value_txt,
                    NULL
               FROM DUAL
         CONNECT BY LEVEL < 7),
     t4
     AS (    SELECT 7 job_request_id,
                    3 original_job_request_id,
                    mod(LEVEL,2) + 1 sequence_cd,
                    CHR (LEVEL + 92) value_txt,
                    NULL
               FROM DUAL
         CONNECT BY LEVEL < 4),
     mytable
     AS (SELECT * FROM t
         UNION ALL
         SELECT * FROM t1
         UNION ALL
         SELECT * FROM t2
         UNION ALL
         SELECT * FROM t3
         UNION ALL
         SELECT * FROM t4)
SELECT *
  FROM mytable
  order by job_request_id, original_job_request_id, sequence_cd;input
JOB_REQUEST_ID     ORIGINAL_JOB_REQUEST_ID     SEQUENCE_CD     VALUE_TXT     NEW_SEQUENCE_CD
1     1     1     g     
1     1     2     h     
1     1     2     e     
1     1     3     i     
1     1     3     f     
2     1     1     v     
2     1     1     p     
2     1     1     r     
2     1     1     t     
2     1     2     u     
2     1     2     q     
2     1     2     o     
2     1     2     s     
2     1     2     w     
3     3     7     b     
3     3     7     e     
3     3     8     `     
3     3     8     f     
3     3     8     c     
3     3     9     d     
3     3     9     a     
3     3     9     g     
4     3     1     e     
4     3     1     c     
4     3     1     a     
4     3     2     b     
4     3     2     `     
4     3     2     d     
7     3     1     ^     
7     3     2     ]     
7     3     2     _     expected output
JOB_REQUEST_ID     ORIGINAL_JOB_REQUEST_ID     SEQUENCE_CD     VALUE_TXT     NEW_SEQUENCE_CD
1     1     1     g     1
1     1     2     h     2
1     1     2     e     2
1     1     3     i     3
1     1     3     f     3
2     1     1     v     4
2     1     1     p     4
2     1     1     r     4
2     1     1     t     4
2     1     2     u     5
2     1     2     q     5
2     1     2     o     5
2     1     2     s     5
2     1     2     w     5
3     3     7     b     7
3     3     7     e     7
3     3     8     `     8
3     3     8     f     8
3     3     8     c     8
3     3     9     d     9
3     3     9     a     9
3     3     9     g     9
4     3     1     e     10
4     3     1     c     10
4     3     1     a     10
4     3     2     b     11
4     3     2     `     11
4     3     2     d     11
7     3     1     ^     12
7     3     2     ]     13
7     3     2     _     13my attempt to explain.
if the job request id = the original job request id the new sequence cd = sequence cd
when the job request ids are higher than the original increment the new sequence cd with respect to the maximim sequence cd of the original job request id.
hopefully the expected output will clarify.

this?
WITH t
     AS (    SELECT 1 job_request_id,
                    1 original_job_request_id,
                    mod(level,3) +1  sequence_cd,
                    CHR (LEVEL + 100) value_txt,
                    NULL new_sequence_cd
               FROM DUAL
         CONNECT BY LEVEL < 6),
     t1
     AS (    SELECT 2 job_request_id,
                    1 original_job_request_id,
                    mod(LEVEL,2) + 1 sequence_cd,
                    CHR (LEVEL + 110) value_txt,
                    NULL
               FROM DUAL
         CONNECT BY LEVEL < 10),
     t2
     AS (    SELECT 3 job_request_id,
                    3 original_job_request_id,
                    mod(LEVEL,3) + 7 sequence_cd,
                    CHR (LEVEL + 95) value_txt,
                    NULL
               FROM DUAL
         CONNECT BY LEVEL < 9),
     t3
     AS (    SELECT 4 job_request_id,
                    3 original_job_request_id,
                    mod(LEVEL,2) + 1 sequence_cd,
                    CHR (LEVEL + 95) value_txt,
                    NULL
               FROM DUAL
         CONNECT BY LEVEL < 7),
     t4
     AS (    SELECT 7 job_request_id,
                    3 original_job_request_id,
                    mod(LEVEL,2) + 1 sequence_cd,
                    CHR (LEVEL + 92) value_txt,
                    NULL
               FROM DUAL
         CONNECT BY LEVEL < 4),
     mytable
     AS (SELECT * FROM t
         UNION ALL
         SELECT * FROM t1
         UNION ALL
         SELECT * FROM t2
         UNION ALL
         SELECT * FROM t3
         UNION ALL
         SELECT * FROM t4)
SELECT job_request_id,
       original_job_request_id,
       sequence_cd,
       value_txt,
       nvl(new_sequence_cd,LAG(new_sequence_cd IGNORE NULLS) OVER (ORDER BY job_request_id, original_job_request_id, sequence_cd)+sequence_cd) new_sequence_cd
FROM(
SELECT job_request_id,
       original_job_request_id,
       sequence_cd,
       value_txt,
       DECODE(job_request_id,
              original_job_request_id,
              sequence_cd,NULL)        new_sequence_cd
  FROM mytable
  order by job_request_id, original_job_request_id, sequence_cd
JOB_REQUEST_ID     ORIGINAL_JOB_REQUEST_ID     SEQUENCE_CD     VALUE_TXT     NEW_SEQUENCE_CD
1     1     1     g     1
1     1     2     h     2
1     1     2     e     2
1     1     3     i     3
1     1     3     f     3
2     1     1     v     4
2     1     1     p     4
2     1     1     r     4
2     1     1     t     4
2     1     2     u     5
2     1     2     q     5
2     1     2     o     5
2     1     2     s     5
2     1     2     w     5
3     3     7     b     7
3     3     7     e     7
3     3     8     `     8
3     3     8     f     8
3     3     8     c     8
3     3     9     d     9
3     3     9     a     9
3     3     9     g     9
4     3     1     e     10
4     3     1     c     10
4     3     1     a     10
4     3     2     b     11
4     3     2     `     11
4     3     2     d     11
7     3     1     ^     10
7     3     2     ]     11
7     3     2     _     11----
Ramin Hashimzadeh

Similar Messages

  • Change Column Value based on Characteristic in Rows

    I am not sure it is possible.
    We have product prices at different levels of customer hierarchy.
    Channel > Division > Region > Market
    One Region can have multiple Markets.  Each market can have different Rates.  But the Region will have a different Rate which many not be the average rate of all market (assigned as part of master data)
    I have a column for Product Price.  So when a Report is run at Market Level it should use Market Rate.  If Market is Removed and Region is dragged into the report it should use Region Rate for Product Price.
    Product Price is Restricted by Rate Type value to determine which Rate is used.
    Is there a way to dynamically determine the define the column value based on the characteristic value in the ROWS.
    Thanks

    Hi,
    For every CHAR like Market/Region there will be some key. For example Maket1 = 11 and Market2 = 22. If that key is a number then you may create replacement path variable on that and convert the same in numbers then you may create various CKF (for various rate type) and put "If" condtion and check for those replacement path CKF and use the apprpriate one.
    You need to write some tricky formula at CKF levels. This is one of the way to achieve that.
    I hope it will help.
    Thanks,
    S

  • Concatenation error - when i use text column value in where condition.

    Hi,
    i am creating Materialized view using few columns from two tables and as per requirement i need to prepare select statement with where condition in another column.(new column)
    i tried like below....
    create materialized view MAIN
    refresh force on demand
    as
    select
    a.table_name,
    a.column_name,
    b.trial_name,
    'select * from '||a.table_name||' where '||a.column_name|| ' = '|| b.trial_name||';' "QUERY"
    from
    exp_csv_tB a,
    exp_csv_tr b;
    a.table name value is : monitoring_table
    a.column_name value is : study
    b.trial_name = fty777
    Materialized view created with extra column but it is not added '' (codes) to text value in where condition.
    output which i got is :
    select * from monitoring_table where study = fty777;
    but
    i need output like
    select * from monitoring_table where study = 'fty777';
    fty777 value should be in codes like 'fty777'. i read some articles but didnt get this example.
    please help.

    Try this:
    CREATE MATERIALIZED VIEW main
    REFRESH FORCE ON DEMAND
    AS
    SELECT
    a.table_name,
    a.column_name,
    b.trial_name,
    'select * from '||a.table_name||' where '||a.column_name|| ' = '''|| b.trial_name||'';'' "QUERY"
    FROM
    exp_csv_tb a,
    exp_csv_tr b;
    You have to give double single codes for semi-colons ..
    Regards..

  • Setting column values based on LOV selection

    Hi All,
    I am using JDeveloper 11.1.2.2.0. I have a table eg: Department table, in Dept Id, I have defined LOV for that field. My requirement is, based on the LOV selection, I want to set the other column values. I am using InputTextwithLOV in list type. How to achieve this?
    I tried mentioning that in the List return values. But it is not setting the values.
    Regards,
    Infy

    Hi,
    if you use a model driven LOV then when configuring the LOV you can map additional attributes. When you build a model driven LOV you at least once tell it which LOV attribute should be used to update the DeptId field. You can do the same for additional attributes
    Frank

  • Change column value based on another

    Hi, everyone.
    my version 11.1.2.2.0.
    i wanna change 1 column's value based on another column's value that be selected.
    ex: select 2rd column to 'A' , then the 1rd should be 'New Start'.
    i used EL like #{row.bindings.MacdType.inputValue eq 1 ? 'New Start' :  row.bindings.CircuitId.inputValue}.
    But it does not set the inputvalue which should binding with the DataSource.
    what's the best way to do these logic?
    pls help. thx

    Hi,Abhijit;
    ex: the frist column is a LOV, the user select "A" for the first column, so the value of the second column should be changed to 'New Start'.
    And the value should be binding to the DC, when save, the value of the 2rd column should be saved to DB.
    thx

  • How to fetch the Alias column values based on different column values?

    Hello Gurus,
    I have a table with the following struture -
    "drop table T;
    create table T(Name, Symbol, Amount,dep) as select
    'Anderia', 'AA', 1050000,'HR' from dual union all select
    'Michael', 'ML',150000,'Sales' from DUAL union all select
    'Bill', 'BL', 1050000,'Finance' from dual union all select
    'Nancy', 'NY', 4000,'HR' from DUAL union all select
    'Anderia', 'AA',3000,'HR' from dual union all select
    'Michael', 'ML',1050000,'Sales' from DUAL union all select
    'Bill', 'BL', 1200000,'Finance' from DUAL union all select
    'Anderia', 'AA', 1200000,'HR' from DUAL union all select
    'Vish', 'VH', 1200000,'Marketing' from DUAL;"Ans try to find out the values of the column like
    Name,symbol,dep,Amount,%Total,$Cumm Total, Rank but some additional columns like -
    HR Amount, %HRTotal,$HR Cumm Total,
    Finance Amount, %FinanceTotal,$Finance Cumm Total
    Sales Amount, %SalesTotal,$Sales Cumm Total,
    Marketing Amount, %MarketingTotal,$Marketing Cumm Total
    then i am using the following query to fetch the Name,symbol,dep,Amount,%Total,$Cumm Total, Rank columns -
    select name
         , decode(grouping(symbol), 0, symbol, 'Total') symbol
         , dep
         , sum(amount) amount
         , sum(per_total) "% Total"
         , decode(grouping(symbol), 0, max(Cum_per_total), null) "% Cumm Total"
         , decode(grouping(symbol), 0, max(rank), null) rank
      from (
              select name
                   , symbol
                , dep
                   , amount
                   , per_total
                   , sum(per_total) over(order by rk) cum_per_total
                   , rank
                   , rk
                from (    
                        select name
                             , symbol
                    , dep
                             , sum(amount) amount
                             , round((sum(amount)/max(total_amount)) * 100,2) per_total
                             , dense_rank () over (order by sum(amount) desc) as rank
                             , row_number() over(order by sum(amount) desc) as rk
                          from (
                                 select name
                                      , symbol
                                      , amount
                          , dep
                                      , sum(amount) over() total_amount
                                      , sum(amount) over ()
                                   from t
                         group
                            by name, symbol, dep
      group        
         by grouping sets((name, symbol, dep), ())
      order by rank, max(rk) nulls lastBut i want to fetch the following columns as well.......how can i do it?-
    HR Amount, %HRTotal,$HR Cumm Total,
    Finance Amount, %FinanceTotal,$Finance Cumm Total
    Sales Amount, %SalesTotal,$Sales Cumm Total,
    Marketing Amount, %MarketingTotal,$Marketing Cumm Total
    as i want all of the records, then going to specific to the dep.....do i need to use the case here?
    Thanks for all of your time and effort in advance

    Hello Frank Kulash/Łukasz Mastaler,
    Thanks for your time and effort.
    I am using the Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    I am looking forward to have some additional columns (column alias) along with the the returned by the mentioned query - which are named as -
    1- HR Amount
    2- %HRTotal
    3- %HR Cumm Total
    4- Finance Amount
    5- %FinanceTotal
    6- %Finance Cumm Total
    7- Sales Amount
    8- %SalesTotal
    9- %Sales Cumm Total
    10 -Marketing Amount
    11- %MarketingTotal
    12- %Marketing Cumm Total
    based on the logic like -
    HR Amount = sum of amount case dep ='HR'
    %HR Total = % of amount case dep ='HR'
    %HR Cumm Total (cumulative % based on the cumulative total of %HR Total) = Cumm % of amount case dep ='HR'
    similarly rest of the column........
    Now how do i use case with a logic so that it returns me the columns as i want them ...using the above mentioned query .......
    Kindly help me .....thanks in advance for all of your time

  • Get a Column value based on other column value in a single query

    Hi All,
    I have a problem here -
    In Table XYZ I have columns by name A, B, C and COL_I. COL_I has a value A or B or C. Based on the value in COL_I, I need to get the value from the corresponding column in the table.
    For Ex: If the COL_I has the value as 'A' then I need to fetch the value from the column A. If it is 'B' then fetch from column B.
    This has to be done in a single query.
    Thanks,
    san_mah

    Hi You can use this query
    I have taken this simple case
    SQL> desc column_fetch
    Name Null? Type
    C_FIRST_NAME VARCHAR2(30)
    C_MIDDLE_NAME VARCHAR2(30)
    C_LAST_NAME VARCHAR2(30)
    C_GET_NAME VARCHAR2(30)
    based on C_GET_NAME find values in columns C_FIRST_NAME,C_MIDDLE_NAME,C_LAST_NAME
    Values in Table
    SQL> select * from column_fetch
    2 ;
    C_FIRST_NAME C_MIDDLE_NAME C_LAST_NAME C_GET_NAME
    A B C D
    A B C F
    A B C F
    A B C A
    A B C B
    A B C C
    CASE Statement:
    SELECT
    CASE WHEN c_first_name=c_get_name THEN c_first_name
    WHEN C_MIDDLE_NAME=C_GET_NAME THEN C_MIDDLE_NAME
    WHEN C_LAST_NAME=C_GET_NAME THEN C_LAST_NAME
    ELSE 'Nothing' END
    FROM column_fetch;

  • Populate other column value based on previous row value using t-sql

    Hi All,
    I have one table with 6 columns, let say ID1, ID2,status, EnteredDate,NewValue, Old Value. Where ID1 is the primary key field
     ID1       ID2       status             EnteredDate        NewValue      
    Old Value
      1          XYZ       New              07/12/2012           
    ABC               null
      2          XYZ       Renewal        08/19/2012            DEF               
    null
      3          XYZ       Cancel           10/21/2012            GHI               
    null
      4          ZYX       New              09/15/2012           
    BDF               null
      5          ZYX       Cancel           10/21/2012            MNS             
    null
      6          MBS       New              05/29/2012           
    EXP               null
      7          SBX        New              05/29/2012           
    SKS               null
      8          SBX        Renewal        06/21/2012            QSR              
    SKS
    Basically I need a sql query which should populate Output as below. Status=New will always have old date compared to Renewal and Cancel and also OldValue field will be null always for status=New
    Output:
     ID1       ID2       status           EnteredDate        NewValue      
    Old Value     Row_Num(based on ID1,ID2,Entereddate)
      1          XYZ       New              07/12/2012           
    ABC               null                 1
      2          XYZ       Renewal        08/19/2012            DEF               
    ABC                2
      3          XYZ       Cancel           10/21/2012            GHI               
    DEF                 3
      4          ZYX       New              09/15/2012           
    BDF               null                   1
      5          ZYX       Cancel           10/21/2012            MNS              
    BDF                 2
      6          MBS       New              05/29/2012           
    EXP               null                  1
      7          SBX        New              05/29/2012           
    SKS               null                  1
      8          SBX        Renewal        06/21/2012            QSR              
    SKS                2
    Thanks in Advance, its very urgent. Pls send me the query ASAP.
    RH
    sql

    Hi,
    In case of you are using SQL 2012, you can use new built-in function like LAG, try this;
    USE tempdb
    GO
    CREATE TABLE dbo.Test
    ID1 int PRIMARY KEY
    , ID2 char(3) NOT NULL
    , Status varchar(20) NOT NULL
    , EnteredDate date NOT NULL
    , NewValue char(3) NOT NULL
    , OldValue char(3) NULL
    GO
    INSERT INTO dbo.Test
    (ID1, ID2, Status, EnteredDate, NewValue, OldValue)
    VALUES
    (1, 'XYZ', 'New', '07/12/2012', 'ABC', null)
    , (2, 'XYZ', 'Renewal', '08/19/2012', 'DEF', null)
    , (3, 'XYZ', 'Cancel', '10/21/2012', 'GHI', null)
    , (4, 'ZYX', 'New', '09/15/2012' ,'BDF', null)
    , (5, 'ZYX', 'Cancel', '10/21/2012', 'MNS',null)
    , (6, 'MBS', 'New', '05/29/2012', 'EXP', null)
    , (7, 'SBX', 'New', '05/29/2012', 'SKS', null)
    , (8, 'SBX', 'Renewal', '06/21/2012', 'QSR', 'SKS')
    WITH cte
    AS
    (SELECT ID1, ID2, Status, EnteredDate, NewValue, OldValue
    , ROW_NUMBER() OVER(PARTITION BY ID2 ORDER BY ID2) Row_Num
    , LAG(NewValue, 1, 0) OVER(PARTITION BY ID2 ORDER BY ID2) NewOldValue
    FROM dbo.Test)
    SELECT ID1, ID2, Status, EnteredDate, NewValue
    , NULLIF(NewOldValue, '0') NewOldValue, Row_Num
    FROM cte
    ORDER BY ID1, ID2;
    Dinesh Priyankara
    http://dinesql.blogspot.com/
    Please use Mark as answer (Or Propose as answer) or Vote as helpful if the post is useful.

  • Formula to Copy all the values based on condition

    Hi All,
          I have Text Column called "PASS" in Pivot table holding values like and NA and 0.0133333333333333 .
          So I want to create the calculate column "CALS "and copy all the values which are not holding NA into this column and set value 0 if found NA.Can any one help me how can I solve this.
    Thanks,
    Sid

    Hello Sid,
    For this you can use a calculate column a simple condition with the IF function like
    =IF(MyTable[MixedValueColumn] = "NA", 0, CURRENCY(MyTable[MixedValueColumn]))
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Selection Screen search help values based on condition

    Hi All,
    I am developing this report for HR.And the requirement is in one of the selection screen field the
    value's should be appeared(when f4) based on some condition,ie not all values should come.
    My field is HRP1001-sobid,here there are many values,they dunt want all that to be shown when user
    tries to input the values(F4).And also i need to show the Text for this field(department name) in
    search help.
    Can anyone please guide...
    Thanks in advance.

    Hi Salz
    You can code your own search help procedure for this. To achieve this, first you should add the block:
    <u>e.g.</u>
    AT SELECTION-SCREEN ON VALUE REQUEST FOR p_sobid.
    Within this block you can use the standard FM "<b>RH_OBJID_REQUEST</b>" to call the standard HR help list for objects conditionally.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

  • Cumulative keyfigure value based on condition

    Hi All,
    I have a requirement where in I need to display cumulative results on keyfigures. At present I am displaying  keyfigures values for fiscal year & fiscal period included in query at column level.
    But, If user add  comapny code (from filter) & removes fiscal period at run time (in BEx screen), the data is displayed cumulative across company codes.
    The requirement is: data should get displayed cumulative based on company code codes. 
    Kindly suggest your inputs.
    -Thanks
    Shamkant

    Hi Shamkanth,
    In general we will use time char for calculation of time fields but when we are using for calculation purpose ,we have to consider key figures for developing time fields.
    The reason why we have to use is: at the time of dril down with respect ton other fields across the report,it will show exact result but we if we use time char it will show wrong counter.
    Hope this helps you..
    Best Regards,
    maruthi

  • How to re-calculate a column value based on another column value in the same ADF Table row

    Hi,
    I'm using Jdeveloper 11.1.2.3.0.
    I have an adf table with 2 columns, columnA and columnB.
    When the value changed in ColumnA,
    1) i need to call a PLSQL and update the ColumnB value that is returned from PLSQL.
    2) Show a warning message if the existing value in ColumnB is different from the one that is returned from PLSQL.
    Can anybody suggest how can i accomplish this?
    Thanks,
    Vinod

    hi user,
    if you have inputtext means have a valuechangelistener
    in that call your pl/sql function supply input value to the appropriate function then grab the result of the function. then bind the column inputtext and compare with it. then raise your warning using FacesMessage classes.
    Sameh Nassar: Create PL/SQL Function And Call It From Your ADF Application

  • Generate output values based on contexts

    Queue 1 :
    contextchange
    mat_name1
    contextchange
    mat_name2
    contextchange
    mat_name3
    contextchange
    mat_name4
    contextchange
    Queue 2: ( output from Boolean AND)
    contextchange
    true
    contextchange
    true
    true
    contextchange
    true
    true
    true
    contextchange
    false
    true
    contextchange
    Based on the 2 Queues, I shud get the following output :
    contextchange
    mat_name1
    contextchange ( based on 2 true values of the queue 2)
    mat_name2
    mat_name2
    contextchange ( based on 3 true values of Queue 2)
    mat_name3
    mat_name3
    mat_name3
    contextchange ( based on 1 true value of Queue 2)
    mat_name4       (because false ignore II ocurance)
    how do I achieve this?
    regards,
    nikhil.
    ***each useful reply will be awarded***

    Hi,
    contextchange
    true
    contextchange
    true
    true
    contextchange
    true
    true
    true
    contextchange
    false
    true
    contextchange
    remove false from the above context. then ur output will be
    contextchange
    true
    contextchange
    true
    true
    contextchange
    true
    true
    true
    contextchange
    true
    contextchange
    now u can use UseoneAsmany.
    chirag

  • Programatically Assigning Column Value Based on Another Column

    I have a problem as follows:
    My database table has the following setup:
    There may be many gift numbers the same, however many different recipient numbers for each gift.
    The receipient number should increment from 1-X based on the gift number, for example, if the gift number is the same then the receipient number should increment for that gift.
    Gift Number
    Recipient Number
    1
    1
    1
    2
    1
    3
    2
    1
    3
    1
    3
    2
    The programmatic code for inserting a new row would be:
    Check if gift number already exsists in database.
    -if it does exsist then find latest and increment current receipient number by one for receipment number
    -if it does not exsit set receipient number at 1
    How do i do this?
    JDEV - 11.1.2.4 (ADF BC)

    Your use case has some flaws which you should think about before trying to implement it.
    1) think about what happens if multiple users try to insert a record at the same time. What can happen? How do you want to handle this situation?
    2) do you really need the number to be gap less? The use case can be implemented easily if you don't have this restriction.
    3) The table should have the technical primary key to avoid pk clashes due to multiple inserts at one time.
    Now, if you have a technical pk as primary key, you can setup a unique key on both of the other columns which prevents that somehow you get duplicates there.
    You let the user insert the gift number and calculate the recipient number as max(recipient number)+1. Then you commit the record. If you don't get an error you are finished, if you get an error you add 1 to the recipient number and try to commit again, until the insert works.
    Timo

  • Column Values based on different parameters

    Hi Gurus,
    I have to create a report which has the caluculate #of installes, #of orders, # Completed on perticular date range in single report (kind a dashboard).
    The # of installs need to calculated based on Install date range based on Installed date, #of orders need to calculated in Order date range based on order date and # of Completed on Completed date.
    Could you please help me how to create for this kind of situation.
    example: for last 10 days the number of Installs are 10 and orders are 20 and completed is 5.
    can i create report like this
    Division | Region | Intalls | orders |completed
    filter
    install date between last 10 days or
    order date between last 10 days or
    completed date between last 10 days.
    or in need to create the combined request.
    Thanks in advance
    Regards
    Ali

    Hi Ali,
    As per your requirement, you suppose create a view like
    select division,region.sum(installs),sum(orders),sum(completed),aging from
    (select division,region, sum(installs) installs, 0 orders,o completed, case when timestampdiff(SQL_TSI_DAY,tablename.install_date,current_date) between 0 and 10 then 'Less than 10 Days'
    when timestampdiff(SQL_TSI_DAY,tablename.install_date,current_date) between 11 and 25 then '10-25 Days'
    else '> 25 Days' end Aging
    group by division,region,case when timestampdiff(SQL_TSI_DAY,tablename.install_date,current_date) between 0 and 10 then 'Less than 10 Days'
    when timestampdiff(SQL_TSI_DAY,tablename.install_date,current_date) between 11 and 25 then '10-25 Days'
    else '> 25 Days' end
    union all
    select division,region, 0 installs, sum(orders) orders,o completed, case when timestampdiff(SQL_TSI_DAY,tablename.order_date,current_date) between 0 and 10 then 'Less than 10 Days'
    when timestampdiff(SQL_TSI_DAY,tablename.order_date,current_date) between 11 and 25 then '10-25 Days'
    else '> 25 Days' end Aging
    group by division,region,case when timestampdiff(SQL_TSI_DAY,tablename.order_date,current_date) between 0 and 10 then 'Less than 10 Days'
    when timestampdiff(SQL_TSI_DAY,tablename.order_date,current_date) between 11 and 25 then '10-25 Days'
    else '> 25 Days' end
    union all
    select division,region, 0 installs, 0 orders,sum(completed) completed, case when timestampdiff(SQL_TSI_DAY,tablename.completed_date,current_date) between 0 and 10 then 'Less than 10 Days'
    when timestampdiff(SQL_TSI_DAY,tablename.completed_date,current_date) between 11 and 25 then '10-25 Days'
    else '> 25 Days' end Aging
    group by division,region,case when timestampdiff(SQL_TSI_DAY,tablename.completed_date,current_date) between 0 and 10 then 'Less than 10 Days'
    when timestampdiff(SQL_TSI_DAY,tablename.completed_date,current_date) between 11 and 25 then '10-25 Days'
    else '> 25 Days' end
    group by division,region,aging
    *(Note : Create aging based on your requirement)*
    create a dashboard prompt on Aging
    hope u understand....
    Cheers,
    Aravind

Maybe you are looking for