CASE WHEN THEN END

Hello everyone,
We have a function return Y or N.
We have 2 table YTable YT and NTable NT.
We are using UNION now.
SELECT ONE.CL1
FROM (
SELECT CL1Y FROM YTable WHERE FUNCTION = 'Y'
UNION
SELECT CL1N FROM NTable WHERE FUNCTION = 'N') ONEWe are wondering to use CASE, WHEN, THEN, END.
Is it possible or NOT?
If you have a chance, please share your experiences.
Thanks in advance,
NY
P.S.
If you have more questions, please let us know.
Edited by: New Yorker on Aug 31, 2010 10:08 AM

New Yorker,
According to the given SQL block, the case function can not be used. You can use the case function with multiple table joins but you can only use the CASE WHEN ELSE END block for one column.
If i got your question correct, that is my answer to your question.
Regards.
Ogan

Similar Messages

  • Case when then not working

    In my database, two variable ID and time (varchar2) are there. I want to populate another variable using case when then by putting below conditon to convert like this
    But its not working. Can anyone help me
    if time =1 day then '1 Day'
    time > 2 days and time <=7 days then '2 to 7 days'
    time > 8 days and time <=15 days then '8 to 15 days'
    else 'not matching'
    ID Time
    12 1 days
    23 244 days
    12 2 days
    14 4 days
    15 6 days
    17 9 days
    select time,
    case WHEN
    UPPER(Time) = '1 DAY'
    THEN
    '1 day'
    WHEN
    UPPER(Time) Between '2 DAYS' and '7 DAYS'
    THEN
    '2 to 7 days'
    WHEN
    UPPER(Time) Between '8 DAYS' and '15 DAYS'
    THEN
    '8 to 15 days'
    ELSE
    'Not matching'
    END "update time"
    from table1

    900487 wrote:
    In my database, two variable ID and time (varchar2) are there. If you are storing Days in a column store it as NUMBER or INTERVAL data type. The way you have stored the value looks incorrect.
    What you can do is extract the number portion of your time column and apply the CASE statement. Something like this
    SQL> with t
      2  as
      3  (
      4  select 12 id, '1 days' time1 from dual union all
      5  select 23 id, '244 days' time1 from dual union all
      6  select 12 id, '2 days' time1 from dual union all
      7  select 14 id, '4 days' time1 from dual union all
      8  select 15 id, '6 days' time1 from dual union all
      9  select 17 id, '9 days' time1 from dual
    10  )
    11   select id,
    12          time1,
    13          case when time1 = 1              then '1 day'
    14               when time1 between 2 and 7  then '2 to 7 days'
    15               when time1 between 8 and 15 then '8 to 15 days'
    16               else 'not matching'
    17          end "update time"
    18     from (
    19              select id, to_number(regexp_substr(time1, '^[[:digit:]]*')) time1
    20                from t
    21          )
    22  /
            ID      TIME1 update time
            12          1 1 day
            23        244 not matching
            12          2 2 to 7 days
            14          4 2 to 7 days
            15          6 2 to 7 days
            17          9 8 to 15 days
    6 rows selected.

  • Case-when-then logic in join condition

    Is it possible to implement case when then logic in join condition?
    Instead of:
    INGRP1.COL1 = INGRP2.COL1 (+)
    something like:
    case
    when INGRP1.COL2 IS NULL
    then INGRP1.COL1 = INGRP2.COL1 (+)
    else INGRP1.COL3 = INGRP2.COL3 (+)
    end
    expression builder for join condition.
    Any help much appreciated.

    Hi Kaiser,
    this is my variant
    1) join first table with second table twice (define two input group in join, include second table in mapping twice and map them to appropriate join group)
    INGRP1.COL1=INGRP2.COL1(+) and INGRP1.COL3=INGRP3.COL3(+)
    2) after join calculate attributes from second table with expression like
    case when COL2 IS NULL the INGRP2_ATTR else INGRP3_ATTR end
    Maybe anyone has a better solution...
    Regards,
    Oleg

  • Using CASE WHEN THEN in dynamic Region Source area

    Hi all,
    I've been knocking my head around on this one for a while. Hope someone can show me some guidance. So far, the SQL Query in the Region Source works ok except after the THEN ''||'LINK'||'' . All text between the single quotes displays, and not just the hyperlink LINK. (My goal is to this simple test working, then go back an substitute in APP_ID, Page#, SESSION variables.) But I'm stuck with this problem. Searched the forum but this is as far as I got. Below is the code I'm using in the Region Source area. Perhaps a region attribute setting is needed but I'm unsure. Thanks for any assistance. -Mike
    select DISTINCT
        AWARD,
        CASE
        WHEN WINNER_NAME = 'India Retail Support Team'
       THEN '<A HREF="http://www.hotmail.com">'||'LINK'||'</A>'         *----------------HREF link (LINK) is working fine here but doesn't work ok in Region Source.
        ELSE WINNER_NAME
        END WN,
            GBU_WINNER,
            DORDER
    from   GBUSERVICEPACESETTERAWARDS
    where FY = '2012'
    and TYPE = 'Service Award'

    >
    As previously requested, please update your forum profile with a real handle instead of "user10734329".
    I've been knocking my head around on this one for a while. Hope someone can show me some guidance. So far, the SQL Query in the Region Source works ok except after the THEN ''||'LINK'||'' . All text between the single quotes displays, and not just the hyperlink LINK.Not clear from this what the problem is. It appears to me that LINK is all of the "text between the single quotes". What do you mean by "all text"? (An example on apex.oracle.com is a good way to resolve such ambiguities...)
    The usual cause of unexpected results when the separation of concerns is breached and HTML is directly generated in report queries is having the Display Text As report column attribute wrongly set. Ensure it is Standard Report Column rather than the default Display as Text (escape special characters).

  • My nested CASE WHEN THEN ELSE is not working.

    I'm working on a report that will provide a status on a component based on a defined Matrix.  The status to report is determined in a hierarchal fashion...the highest seqence number status existing is reported. 
    I've capped the sequence number at 10 (@SeqNumCap_sav)
    The matrix table is defined as such:
    CREATE TABLE [dbo].[tblAssyLineComponentStatusMatrix](
    [MatrixAssyLine] [char](1) NOT NULL,
    [MatrixComponentProduct] [char](15) NOT NULL,
    [MatrixComponentStatusSequence] [decimal](3, 0) NOT NULL,
    [MatrixComponentStatus] [char](3) NOT NULL,
    [MatrixStatusDescription] [nvarchar](100) NOT NULL,
    [MatrixReportedDescription1] [nvarchar](50) NOT NULL,
    [MatrixReportedDescription2] [nvarchar](50) NULL,
    [MatrixReportedDescription3] [nvarchar](50) NULL,
    [MatrixReportedDescription4] [nvarchar](50) NULL,
    [MatrixReportedDescription5] [nvarchar](50) NULL
    ) ON [PRIMARY]
    This is a sample of the tblAssyLineComponentStatusMatrix data:
    MatrixAssyLine MatrixComponentProduct MatrixComponentStatusSequence MatrixComponentStatus MatrixStatusDescription MatrixReportedDescription1 MatrixReportedDescription2 MatrixReportedDescription3 MatrixReportedDescription4 MatrixReportedDescription5
    E Mast/PullRod    1 W   The part has been stamped or welded. Class3PullRods NULL NULL NULL NULL
    E Mast/PullRod    2 P   The part has been clicked off in a paint hang station. TSMastPaintHang NULL NULL NULL NULL
    E Mast/PullRod    3 Y   The part has been clicked off in paint pulldown. TSMastPaintUnload NULL NULL NULL NULL
    the tblProductionControlComponentReporting is defined as:
    CREATE TABLE [dbo].[tblProductionControlComponentReporting](
    [WorkUnit] [nvarchar](15) NOT NULL,
    [Description] [nvarchar](50) NOT NULL,
    [Completed] [datetime] NOT NULL,
    [UserID] [nvarchar](30) NULL,
    [StationID] [nvarchar](30) NULL,
    [Undo] [bit] NULL,
    [CompletedUndo] [datetime] NULL,
    [UserIDUndo] [nvarchar](30) NULL,
    [StationIDUndo] [nvarchar](30) NULL,
    [ComponentPartNo] [varchar](15) NULL,
    [ComponentClass] [varchar](3) NULL,
    [ComponentQty] [decimal](6, 2) NULL,
    [ComponentScheduleDate] [datetime] NULL,
    [ComponentScheduleShift] [decimal](1, 0) NULL,
    [ComponentScheduleWorkunitSequence] [int] NULL,
    [ComponentComment] [varchar](200) NULL
    ) ON [PRIMARY]
    A sample of the tblProductionControlComponentreporting data:
    assyline WorkUnit Description Completed UserID StationID
    E 639422 Class3PullRods 2014-09-15 13:15:44.607 GLOBAL\agmesusr ag2100156
    E 639422 Class3PullRods 2014-09-15 13:15:44.607 GLOBAL\agmesusr ag2100156
    E 639422          TSFrameFabDeliver 2014-09-25 11:31:44.380 NULL MCA
    E 639422 TSMastPaintHang 2014-09-25 22:56:43.740 009932 AG2100294
    The problem is that the below code is returning multple records which is causing an error ... if I resequence the above Matrix table data where #3 becomes #10, 2 becomes #9 and 1 becomes #8, the query works fine - but this approach doesn't allow for easy
    expansion of the data.  Can anyone help me see the problem here?
    use eschedule
    declare @Workunit varchar(max)
    declare @SeqNumCap_sav dec(3, 0)
    set @WorkUnit='639422'
    set @SeqNumCap_sav= (select top 1 SequenceValueCap from tblAssyLineComponentStatusMatrix_SequenceCap order by SequenceValueCap)
    select
    Mast_PullRodStatus = case
    --Seq 10 Mast/PullRod Component Status
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix where MatrixComponentProduct='Mast/PullRod' and MatrixComponentStatusSequence=@SeqNumCap_sav and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then
    (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=@SeqNumCap_sav
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 9 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-1)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-1)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 8 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-2)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-2)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 7 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-3)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-3)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 6 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-4)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-4)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 5 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-5)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-5)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 4 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-6)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-6)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 3 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-7)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-7)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    --Seq 2 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-8)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod' and MatrixComponentStatusSequence=(@SeqNumCap_sav-8))
    --Seq 1 Mast/PullRod Component Status
    else case
    when (select top 1 [description] from tblproductioncontrolcomponentreporting
    where ([description] = (select MatrixReportedDescription1 from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-9)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))))
    and Workunit=@WorkUnit
    --and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit))
    ) is not null
    then (select MatrixComponentStatus from tblAssyLineComponentStatusMatrix
    where MatrixComponentProduct='Mast/PullRod'
    and MatrixComponentStatusSequence=(@SeqNumCap_sav-9)
    and (MatrixAssyLine=(select assyline from tblProductionControlHeader h where h.workunit=@WorkUnit)))
    else ' '
    end
    end
    end
    end
    end
    end
    end
    end
    end
    end
    Assume Assyline='E'
    Eva Leggett

    Good job posting the DDL.
    Your example data should be in a table format though.
    DECLARE @tblAssyLineComponentStatusMatrix TABLE (MatrixAssyLine char(1) NOT NULL, MatrixComponentProduct char(15) NOT NULL, MatrixComponentStatusSequence decimal(3, 0) NOT NULL, MatrixComponentStatus char(3) NOT NULL, MatrixStatusDescription nvarchar(100) NOT NULL, MatrixReportedDescription1 nvarchar(50) NOT NULL, MatrixReportedDescription2 nvarchar(50) NULL, MatrixReportedDescription3 nvarchar(50) NULL, MatrixReportedDescription4 nvarchar(50) NULL, MatrixReportedDescription5 nvarchar(50) NULL)
    INSERT INTO @tblAssyLineComponentStatusMatrix (MatrixAssyLine, MatrixComponentProduct, MatrixComponentStatusSequence, MatrixComponentStatus, MatrixStatusDescription, MatrixReportedDescription1, MatrixReportedDescription2, MatrixReportedDescription3, MatrixReportedDescription4, MatrixReportedDescription5) VALUES ('E' ,'Mast/PullRod' ,1 ,'W' ,'The part has been stamped or welded. ','Class3PullRods ' ,NULL, NULL, NULL, NULL)
    INSERT INTO @tblAssyLineComponentStatusMatrix (MatrixAssyLine, MatrixComponentProduct, MatrixComponentStatusSequence, MatrixComponentStatus, MatrixStatusDescription, MatrixReportedDescription1, MatrixReportedDescription2, MatrixReportedDescription3, MatrixReportedDescription4, MatrixReportedDescription5) VALUES ('E' ,'Mast/PullRod' ,2 ,'P' ,'The part has been clicked off in a paint hang station. ','TSMastPaintHang ' ,NULL, NULL, NULL, NULL)
    INSERT INTO @tblAssyLineComponentStatusMatrix (MatrixAssyLine, MatrixComponentProduct, MatrixComponentStatusSequence, MatrixComponentStatus, MatrixStatusDescription, MatrixReportedDescription1, MatrixReportedDescription2, MatrixReportedDescription3, MatrixReportedDescription4, MatrixReportedDescription5) VALUES ('E' ,'Mast/PullRod' ,3 ,'Y' ,'The part has been clicked off in paint pulldown. ','TSMastPaintUnload ' ,NULL, NULL, NULL, NULL)
    DECLARE @tblProductionControlComponentReporting TABLE (WorkUnit nvarchar(15) NOT NULL, Description nvarchar(50) NOT NULL, Completed datetime NOT NULL, UserID nvarchar(30) NULL, StationID nvarchar(30) NULL, Undo bit NULL, CompletedUndo datetime NULL, UserIDUndo nvarchar(30) NULL, StationIDUndo nvarchar(30) NULL, ComponentPartNo varchar(15) NULL, ComponentClass varchar(3) NULL, ComponentQty decimal(6, 2) NULL, ComponentScheduleDate datetime NULL, ComponentScheduleShift decimal(1, 0) NULL, ComponentScheduleWorkunitSequence int NULL, ComponentComment varchar(200) NULL)
    INSERT INTO @tblProductionCOntrolComponentReporting (WorkUnit, Description, Completed, UserID, StationID) VALUES (639422, 'Class3PullRods', '2014-09-15 13:15:44.607', 'GLOBAL\agmesusr', 'ag2100156')
    INSERT INTO @tblProductionCOntrolComponentReporting (WorkUnit, Description, Completed, UserID, StationID) VALUES (639422, 'Class3PullRods', '2014-09-15 13:15:44.607', 'GLOBAL\agmesusr', 'ag2100156')
    INSERT INTO @tblProductionCOntrolComponentReporting (WorkUnit, Description, Completed, UserID, StationID) VALUES (639422, 'TSFrameFabDeliver', '2014-09-25 11:31:44.380', NULL, 'MCA')
    INSERT INTO @tblProductionCOntrolComponentReporting (WorkUnit, Description, Completed, UserID, StationID) VALUES (639422, 'TSMastPaintHang', '2014-09-25 22:56:43.740', '009932', 'AG2100294')
    Your code is a mess, it would take longer to untangle it that it would to solve your problem.
    Can you give us an expected output, and perhaps the rules governing what your case statement should be doing?

  • Using case when statement or decode stament in where clause

    hi gems..
    i have a problem in the following query..
    i am trying to use case when statement in the where clause of a select query.
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
    cr.salary as salary
    from customer_details cr
    where (case when '>' = '>' then 'cr.salary > 5000'
    when '>' = '<' then 'cr.salary < 5000'
    when '>' = '=' then 'cr.salary = 5000'
    else null
    end);
    the expression in the when clause of the case-when statement will come from UI and depending on the choice i need to make the where clause.
    thats why for running the query, i have put '>' in that place.
    so the original query will look like this(for your reference):
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
    cr.salary as salary
    from customer_details cr
    where (case when variable = '>' then 'cr.salary > 5000'
    when variable = '<' then 'cr.salary < 5000'
    when variable = '=' then 'cr.salary = 5000'
    else null
    end);
    so, in actual case,if the user selects '>' then the filter will be "where cr.salary > 5000"
    if the user selects '<' then the filter will be "where cr.salary < 5000"
    if the user selects '=' then the filter will be "where cr.salary = 5000"
    but i am getting the error "ORA 00920:invalid relational operator"
    please help..thanks in advance..

    Hi,
    select cr.customer_name || ' - ' ||cr.customer_number as cust_name,
           cr.salary                                      as salary
    from customer_details cr
    where (    v_variable = 'bigger'
           and cr.salary > 5000
       or (    v_variable = 'less'
          and cr.salary < 5000
       or (    v_variable = 'eq'
            and cr.salary = 5000
           )Edited by: user6806750 on 22.12.2011 14:56
    For some reason I can't write in sql '<', '>', '='

  • Using Case When

    I have a situation where i need to write a case when sql expression to fetch certain rows from a table.
    How to use CASE WHEN THEN ELSE END in a report query ?
    Explanation with a simple example will be of great help.
    thanks

    The javadoc for oracle.toplink.expressions.Expression
    contains some information.
    The following is an example of how to build the case statement.
    This will use case to replace the keys in the caseTable with the values. The default value (the ELSE) is provided as the second argument.
         Hashtable caseTable = new Hashtable(3);
         caseTable.put("Bob", "Bobby");
         caseTable.put("Susan", "Susie");
         caseTable.put("Eldrick", "Tiger");
         Expression expression = builder.get("firstName").caseStatement(caseTable, "No-Nickname").equal("Bobby");

  • "CASE WHEN 1=0 THEN.......ELSE....END"??

    This might be very basic question still I'm confused about it.
    Can you please explain me "CASE WHEN 1=0 THEN.......ELSE....END"?
    Where and why to use this statement??
    Help appreciated.

    First let's break down what it means. Since 1 is never equal to 0, OBI will ignore what comes immediately after and execute what comes after the ELSE.
    So why would we want to do this? Well, often we want to perform some action that has nothing to do with a particular column in our subject area. By using this CASE statement, we trick OBI into thinking we are using a column for a calculation or action, but in effect, the column is unchanged.
    For example, suppose you were building a dashboard prompt. You want to use a column twice in your dashboard prompt, say an ACCOUNT_OPEN_DATE column to get a range of dates. You cannot use the same column twice in a dashboard prompt. (Try it, OBI will ignore your attempt to put the same column twice into your workspace.)
    So what do you do? First you get a column (in this example, I'm using a CHAR column) like Branch Name. It doesn't matter what column you use. The CHAR is used so the syntax makes sense.
    You move the column to your workspace. Now you click on the Edit Formula and you type CASE WHEN 1=0 THEN Organization."Branch Name" ELSE 'TEST' END.
    So in this case, the values of Branch Name are unaffected and the dummy column just represents the word 'TEST.' Now in the "Show" part of the prompt, we switch to "SQL Results" and type SELECT "Account Attributes".Account_Open_Date FROM Subject Area and set this to a PV called StartDate.
    Because the column is a dummy, you can actually call it again. Use the same CASE statement to make it a "dummy" column. Then use the same SQL you used above, but this time save it to a PV called EndDate.
    Now you have two date values you can use on your ACCOUNT_OPEN_DATE column to get a range of dates.
    So, in conclusion, normally you choose a column from your subject area, because you need the values of that column in your report. But when you just need a column to do something unrelated to any column, you use the CASE 1=0 to make it a "dummy" column and then you can perform your action.
    HTH,

  • CASE WHEN statement IS NULL THEN  ......

    -- i've table's acoount and owner
    create table account
    ( code-number(30) , name-nvarchar(200)) 
    create table owner
    ( code-nvarchar2(20 BYTE) ,
    name -nvarchar(100),
    account_code-number(30))  account_code is foreign key
    code
    name
    account_code
    1.1
    a
    1.1
    5
    x
    5
    3.3
    c
    3.3
    7
    y
    19
    dd
    code
    name
    1.1
    z
    5
    b
    3.3
    c
    3.3
    c
    now my result should be
    code(owner)
    name(owner)
    code(account)
    name(account)
    1.1
    a
    1.1
    z
    5
    x
    5.
    b
    3.3
    c
    3.3
    c
    7
    y
    19
    dd
    my script
    SELECT CASE WHEN O.ACCOUNT_CODE IS NULL THEN A.CODE=NULL  ELSE A.CODE=(VALUE) END,  // HOW SHOULD I WRTIE HERE ???
                 CASE WHEN O.ACCOUNT_CODE IS NULL THEN  A.NAME=NULL  ELSE A.NAME=(VALUE) END,
             O.CODE,
             O.NAME
        FROM OWNER  O,
                  ACCOUNT  A
       WHERE     A.CODE = O.ACCOUNT_CODE;

    I don't see the need for case statement here. Cant you just do this.
    SQL> with owner
      2  as
      3  (
      4  select 1.1 code, 'a ' name, 1.1  account_code from dual union all
      5  select 5   code, 'x ' name, 5    account_code from dual union all
      6  select 3.3 code, 'c ' name, 3.3  account_code from dual union all
      7  select 7   code, 'y ' name, null account_code from dual union all
      8  select 19  code, 'dd' name, null account_code from dual
      9  ), account
    10  as
    11  (
    12  select 1.1 code, 'z' name from dual union all
    13  select 5   code, 'b' name from dual union all
    14  select 3.3 code, 'c' name from dual union all
    15  select 3.3 code, 'c' name from dual
    16  )
    17  select o.code "code (owner)"
    18       , o.name "name (owner)"
    19       , a.code "code (account)"
    20       , a.name "name (account)"
    21    from owner o
    22    left
    23    join (
    24           select distinct code, name
    25             from account
    26         ) a
    27      on o.account_code = a.code
    28   order
    29      by 1;
    code (owner) name (owner)    code (account) name (account)
             1.1 a                          1.1 z
             3.3 c                          3.3 c
               5 x                            5 b
               7 y
              19 dd

  • 'max case when...then' does it work in Desktop reports as a calculation?

    Hi!
    I've used 'max case when...then' in my SQL in Admin edition. It works fine. However when I try to use it as a part of my calculation:
    MAX(CASE
    WHEN (:Payroll Month 1 - Gross Sal)
    THEN TO_NUMBER(NVL("Gross Salary ".Basic Salary, 0)) Else 0 END)
    in this manner, it gives me the error message that
    'Error in formula - Unexpected end of formula - syntax error : Token THEN at position 52'
    Can someone guide me please?
    Thanks and regards,
    Aparna

    Aparna.
    You cannot - without some function coding - pass Discoverer run time parameters to the Admin edition (ie: to a folder, SQL view, etc.).
    If you're tyring to write a calculation like you describe, can't this just be in the Plus or Desktop version and not Admin?
    So, it's a calculation in the report and not the EUL?
    Russ

  • "case when not m[1] is present then" outputs ORA-03113

    I find that "case when not m[1] is present then" outputs ORA-03113:
    Why?
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    select * from dual model
    dimension by(0 as d)
    measures(1 as m)
    rules(
    m[any] = case when not m[1] is present then 1 end);
    ORA-03113:Below one is alterNative solution.
    select * from dual model
    dimension by(0 as d)
    measures(1 as m)
    rules(
    m[any] = case when presentv(m[1],1,0) = 0 then 3 end);
    D  M
    0  3

    I get:
    ops$me%DB>  select * from dual model
      2    dimension by(0 as d)
      3    measures(1 as m)
      4    rules(
      5    m[any] = case when not m[1] is present then 1 end);
    select * from dual model
    ERROR at line 1:
    ORA-03002: operator not implemented
    Elapsed: 00:00:00.03
    ops$me%DB> select banner from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
    NLSRTL Version 10.2.0.4.0 - Production

  • Using case when statement in the select query to create physical table

    Hello,
    I have a requirement where in I have to execute a case when statement with a session variable while creating a physical table using a select query. let me explain with an example.
    I have a physical table based on a select table with one column.
    SELECT 'VALUEOF(NQ_SESSION.NAME_PARAMETER)' AS NAME_PARAMETER FROM DUAL. Let me call this table as the NAME_PARAMETER table.
    I also have a customer table.
    In my dashboard that has two pages, Page 1 contains a table with the customer table with column navigation to my second dashboard page.
    In my second dashboard page I created a dashboard report based on NAME_PARAMETER table and a prompt based on customer table that sets the NAME_ PARAMETER request variable.
    EXECUTION
    When i click on a particular customer, the prompt sets the variable NAME_PARAMETER and the NAME_PARAMETER table shows the appropriate customer.
    everything works as expected. YE!!
    Now i created another table called NAME_PARAMETER1 with a little modification to the earlier table. the query is as follows.
    SELECT CASE WHEN 'VALUEOF(NQ_SESSION.NAME_PARAMETER)'='Customer 1' THEN 'TEST_MART1' ELSE TEST_MART2' END AS NAME_PARAMETER
    FROM DUAL
    Now I pull in this table into the second dashboard page along with the NAME_PARAMETER table report.
    surprisingly, NAME_PARAMETER table report executes as is, but the other report based on the NAME_PARAMETER1 table fails with the following error.
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 1756 message: [Oracle][ODBC][Ora]ORA-01756: quoted string not properly terminated. [nQSError: 16014] SQL statement preparation failed. (HY000)
    SQL Issued: SET VARIABLE NAME_PARAMETER='Novartis';SELECT NAME_PARAMETER.NAME_PARAMETER saw_0 FROM POC_ONE_DOT_TWO ORDER BY saw_0
    If anyone has any explanation to this error and how we can achieve the same, please help.
    Thanks.

    Hello,
    Updates :) sorry.. the error was a stupid one.. I resolved and I got stuck at my next step.
    I am creating a physical table using a select query. But I am trying to obtain the name of the table dynamically.
    Here is what I am trying to do. the select query of the physical table is as follows.
    SELECT CUSTOMER_ID AS CUSTOMER_ID, CUSTOMER_NAME AS CUSTOMER_NAME FROM 'VALUEOF(NQ_SESSION.SCHEMA_NAME)'.CUSTOMER.
    The idea behind this is to obtain the data from the same table from different schemas dynamically based on what a session variable. Please let me know if there is a way to achieve this, if not please let me know if this can be achieved in any other method in OBIEE.
    Thanks.

  • Using CASE WHEN to change background color

    I've done this many times without any problems, but this time its a little different situation and I can't get it to work.
    I can use this CASE WHEN statement without any problems.
    CASE WHEN
    NAME in
    (select EMP_REQUEST_NAME from OAX_PTA_LOGGER where
    EMP_REQUEST_NAME = NAME and
    EMP_ASSIST_NAME is null and
    JOB_NO = :P24_JOB_NO)
    THEN
    '<span style="color:brown;background-color:yellow">'||NAME||'</font>'
    ELSE "NAME"
    END
    "NAME",
    But I Cant Get This One to Work
    CASE WHEN
    NAME in
    (select EMP_REQUEST_NAME from OAX_PTA_LOGGER where
    EMP_REQUEST_NAME = NAME and
    EMP_ASSIST_NAME is null and
    JOB_NO = :P24_JOB_NO)
    THEN
    '<span style="color:brown;background-color:yellow">'||NAME_DISPLAY||'</font>'
    ELSE "NAME"
    END
    "NAME" NAME_DISPLAY,
    I'm sure that the problem lies with <"NAME" NAME_DISPLAY> but I can't find my way to a solution.
    Does anyone have any ideas for me?

    I've done this many times without any problems, but this time its a little different situation and I can't get it to work.
    I can use this CASE WHEN statement without any problems.
    CASE WHEN
    NAME in
    (select EMP_REQUEST_NAME from OAX_PTA_LOGGER where EMP_REQUEST_NAME = NAME and
    EMP_ASSIST_NAME is null and
    JOB_NO = :P24_JOB_NO)
    THEN
    (ignore this) span style="color:brown;background-color:yellow">'||NAME||' (ignore this)
    ELSE "NAME"
    END
    "NAME",
    But I Cant Get This One to Work
    CASE WHEN
    NAME in
    (select EMP_REQUEST_NAME from OAX_PTA_LOGGER where EMP_REQUEST_NAME = NAME and
    EMP_ASSIST_NAME is null and
    JOB_NO = :P24_JOB_NO)
    THEN
    (ignore this) span style="color:brown;background-color:yellow">'||NAME||' (ignore this)
    ELSE "NAME"
    END
    "NAME" NAME_DISPLAY,
    I'm sure that the problem lies with <"NAME" NAME_DISPLAY> but I can't find my way to a solution. Does anyone have any ideas for me?

  • Case When Statement and ORA:01722 Invalid number error

    Hi folks, I have posted this under another heading as well under E-business suite so apologies if some you have already seen it but I would really appreciate some help on this one. Any suggestions are most welcome.
    We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
    The period is always a rolling 6 months from sysdate.
    This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
    This is probably over complicated but we are not techie at all so are learning as we go!
    We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
    SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))

    Hi,
    It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
    However, your formula is far more complicated than it needs to be.
    Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
    date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
    GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
    and AbsenceEnd as
    LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
    Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
    SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
    That's it. Not so complicated after all.
    Rod West

  • Case When Statement and ORA:1722 Invalid number error

    Sorry I posted this in the wrong forum - I have the answer now
    Cheers
    HELP!!!
    We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
    The period is always a rolling 6 months from sysdate.
    This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
    This is probably over complicated but we are not Techie at all so are learning as we go! We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
    SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))
    Edited by: CPearce on Sep 25, 2008 8:03 AM

    Hi,
    It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
    However, your formula is far more complicated than it needs to be.
    Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
    date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
    GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
    and AbsenceEnd as
    LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
    Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
    SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
    That's it. Not so complicated after all.
    Rod West

Maybe you are looking for

  • IPod mini battery bar status not accurate

    I just bought an iPod mini but I am not sure if my battery is working properly. When I have fully charged the iPod mini and disconnected from my iBook, the battery status doesn't show full charge. Is something wrong with my battery?

  • Getting audio to work on Compaq SR1520NX

    I'm trying to get audio working on a Compaq SR1520NX. The audio device is AC97, and should be SIS7012 chipset. Linux had no problems with this, and appeared to use the snd-intel8x0 driver. With Solaris 10 1106, prtconf identifies the audio device as

  • MDSHIFT Question

    Essbase 9.3.1 Cube design Measures --Fuel Ops Periods FY2010 --FY10-Jan ----01/01/2010 etc FY2009 --FY09-Jan ----01/01/2009 etc Scenarios --Actual --Forecast Formula: (Create Blocks On Equation is checked in Cube properties) FIX (Forecast) "Fuel Ops"

  • Not Login in OIM 9.0.3

    Hi All, please help me, I installed OIM 9.0.3 on OAS 10.1.3.1 (SOA), during installation I was asked about password admin user xelsysadm I set password such as xelsysadm. After installation I couldn't login in Oracle Identity Manager I use xelsysadm/

  • MacBook + external HDD / Using two libraries??

    Hi there, question for all laptop users. How do I have my main (complete) music library on an external HDD and a partial music library on my MacBook? When I'm onthe go I wish to have some music but my MacBook HDD isnt big enough for my entire music l