Case Statement problem

Hi All,
I am trying to come up with a case statement for the below provided sql but i am not able to do that can you guys help me out
(SELECT NO_OF_DAYS.id_person
FROM NO_OF_DAYS
WHERE NO_OF_DAYS.STATUS = 'Y'
AND NO_OF_DAYS.ID_PERSON = PERSON.ID_PERSON
HAVING (SUM( NO_OF_DAYS.DT_STAT_END
- NO_OF_DAYS.DT_STAT_START)) > 180)
the case statement i am trying to come up with is if the person status start - end date is greater than 180 days then 'y' else 'n' end

Hi.
If you have two tables: NO_OF_DAYS and PERSON and PERSON is a parent table of NO_OF_DAYS this could work:
WITH NO_OF_DAYS AS
     SELECT 1 id_person,TO_DATE('2012-01-01','YYYY-MM-DD') DT_STAT_START, TO_DATE('2012-01-31','YYYY-MM-DD') DT_STAT_END,'Y' status FROM dual UNION
     SELECT 1 id_person,TO_DATE('2012-02-01','YYYY-MM-DD') DT_STAT_START, TO_DATE('2012-02-20','YYYY-MM-DD') DT_STAT_END,'Y' status FROM dual UNION
     SELECT 2 id_person,TO_DATE('2012-01-01','YYYY-MM-DD') DT_STAT_START, TO_DATE('2012-03-31','YYYY-MM-DD') DT_STAT_END,'Y' status FROM dual UNION
     SELECT 2 id_person,TO_DATE('2012-04-01','YYYY-MM-DD') DT_STAT_START, TO_DATE('2012-10-01','YYYY-MM-DD') DT_STAT_END,'Y' status FROM dual
PERSON AS
     SELECT 1 id_person FROM DUAL UNION
     SELECT 2 id_person FROM DUAL
SELECT
     NO_OF_DAYS.id_person,
     CASE WHEN (SUM(NO_OF_DAYS.DT_STAT_END- NO_OF_DAYS.DT_STAT_START)) > 180 THEN 'Y'
          ELSE 'N'
     END y_n
FROM
     NO_OF_DAYS,
     PERSON
WHERE
     NO_OF_DAYS.ID_PERSON = PERSON.ID_PERSON AND
     NO_OF_DAYS.STATUS = 'Y'
GROUP BY NO_OF_DAYS.id_person;
--results
ID_PERSON     Y_N
1          N
2          YHope this helps.
Regards.

Similar Messages

  • Update with case statement problem.

    Hi,
    I have this statement
    update tab_tr set col_rate =
      case
      when col_ern_type in ('031','035','036') then (1.5 * col_rate)
      when col_ern_type in ('041','045','046') then (2 * col_rate)
    end;this statement updated some 2 million rows in the table tab_tr. But the total count of rows for col_ern_type in ('031','035','036', '041','045','046') yeild only around 222642 rows.
    select count(*) from tab_tr where col_ern_type in ('031','035','036', '041','045','046');  --> 222642 rowswhat is the problem with the above update statement.
    Thank you,

    Hi,
    DBA_1976 wrote:
    ... I thought the case statement conditions are counted as the where condition. But ......A CASE expression just takes the place of some other expression, such as a literal, a function, or a column.
    For example, which rows do you think this should update?
    UPDATE  tab_tr
    SET     col_rate  = 100;It would update all rows, of course.
    How about this statement?
    UPDATE  tab_tr
    SET     col_rate  = column_x;Will it only change the rows where column_x are a certain value, or not NULL, or in any way depend on column_x? No, of course not. It will update all rows.
    How about this statement?
    UPDATE  tab_tr
    SET     col_rate  = function_y (col_ern_type);Will it only change the rows where the fucntion returns a certain value? Will it depend on the value in col_ern_type? No, of course not. It calls the function for each row, and whatever the function returns (even if the function returns NULL), that's what goes into col_rate on each row.
    A CASE expression is just something that you can substitute in place of any other expression, such as the literal 100, or the column column_x, or the function function_y in the statements above. Naturally, the value that gets put into col_rate will depend on what the CASE expression returns, but the behavior of the UPDATE statement as a whole will not.

  • Case statement problems in oracle forms 6i

    Hello,
    Any one can help me that how to use case statment in Oracle forms 6i.
    i have read one thread and there was no proper solution so could any one please let me know to use case statement.
    Please also let me know which category i should search for FORMS 6i.
    when i'm using below code with cursor then i'm getting error 103
    database:=11g
    application := forms 6i
    operating system:= win Xp
    code is given below :-
    cursor c1 is
    select nc.nomenclature_id,
    nvl(nc.category_value, 0) master,
    nvl(nc2.category_value, 0) case,
    nvl(nc3.category_value, 0) bundle,
    case
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) > 0 then
    'A' --All packouts Master, Case, Bundle
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) = 0 then
    'B' --Both Master and Case
    when nvl(nc2.category_value, 0) = 0 and
    nvl(nc3.category_value, 0) = 0 then
    'C' --Master Case Only
    else
    'N'
    end code
    from nomn_category nc, --master case
    (select nc2.nomenclature_id,
    nc2.category_value
    from nomn_category nc2
    where nc2.category_id = '230732') nc2,
    (select nc3.nomenclature_id,
    nc3.category_value
    from nomn_category nc3
    where nc3.category_id = '236566') nc3
    Edited by: Rahul on Feb 3, 2012 7:18 PM
    Edited by: Rahul on Feb 3, 2012 7:20 PM

    hello Andreas,
    It is ok but i dont have to use view there.
    i need to use without view, because this code has to be use in FORMS6i.
    But Forms6i doesn't support to case function. i'm newbie in Forms.
    If you can convert to below bold one portion(case) into decode then please help me or
    if you have any idea about Forms6i then please send me any link where is given explanation about excel report that how to make excel report through Forms6i step by step and that excel report should be generate on any dynamic path which is given by user:-
    cursor c1 is
    select nc.nomenclature_id,
    nvl(nc.category_value, 0) master,
    nvl(nc2.category_value, 0) case,
    nvl(nc3.category_value, 0) bundle,
    case
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) > 0 then
    *'A'*
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) = 0 then
    *'B' --Both Master and Case*
    when nvl(nc2.category_value, 0) = 0 and
    nvl(nc3.category_value, 0) = 0 then
    *'C'*
    else
    *'N'*
    end "code"
    from nomn_category nc,
    (select nc2.nomenclature_id,
    nc2.category_value
    from nomn_category nc2
    where nc2.category_id = '230732') nc2,
    (select nc3.nomenclature_id,
    nc3.category_value
    from nomn_category nc3
    where nc3.category_id = '236566') nc3
    thanks

  • SQL Case Statement Problem with Maxdb

    Hello,
    I'm running a J2E application on Netweaver AS. I have on problem that I just cannot figure out.
    The statement works in SQL Studio but when I try to code it it does not work at all.
    select COLA, SUM(CASE WHEN COLB=10 THEN 1 ELSE 0 END) from TABLE group by COLA
    When executed as statement in Java I get:
    Error [javax.servlet.ServletException: java.lang.IllegalStateException: illegal stack size: 4
    contents:
    com.sap.sql.tree.SelectStatement
    com.sap.sql.tree.IntegerLiteral
    com.sap.sql.tree.IntegerLiteral
    com.sap.sql.tree.ComparisonPredicate], with root cause [java.lang.Exception: java.lang.IllegalStateException: illegal stack size: 4
    contents:
    com.sap.sql.tree.SelectStatement
    com.sap.sql.tree.IntegerLiteral
    com.sap.sql.tree.IntegerLiteral
    com.sap.sql.tree.ComparisonPredicate].
    Any thoughts on that? Thanks!
    Edited by: MD on Feb 18, 2009 7:37 PM

    Hi MD,
    with SQL Studio you mean you work with MaxDB?
    Are you sure you're working directly on MaxDB and not with OpenSQL? (That's different!)
    If you want the first, try setting SQL type "vendor" or "native sql". In such case you have to define a new custom datasource through configuration. How that works depends on the version you are using.
    Try to find out what the actual error message is. The stack trace is not enough. There should be more.
    Regards,
    Benny

  • Case statement problem for a column in BMM layer

    Hi friends.
    In physical layer I've a "cardio" column whose data type is INT, and two values comes here either 0 or 1.
    I need to replace 1 by 'YES' and 0 by "NO'.
    For that I changed the datatype of "Cardio" column to CHAR. and in BMM layer I'm using this formula
    CASE WHEN "A Analysis"."C Report"."CARDIO" = '1' THEN 'Yes' ELSE 'No' END
    But this is giving me "Invalid Expression" error.
    Please help me correct this error.
    Help appreciated.

    Hi,
    Your are probably using the column Cardio as a 'source' and as a 'target'.
    So you have to duplicate the cardio column (right mouse click and Duplicate option) in the business model and then apply the formula CASE WHEN "A Analysis"."C Report"."CARDIO" = '1' THEN 'Yes' ELSE 'No' END
    That should work. It is not even necessary to change datatype of Cardio, OBI will handle this for you.
    Regards
    Edited by: wobiee1 on Nov 12, 2008 1:07 PM

  • Problem In Case Statement

    HI ALL,
    in the program,i need to display description based on condition type.
    so we used CASE statement as below in LOOP. ITS not working .
    could anyone please suggest if anything wrong in the following code.
    LOOP AT gt_mat.
           MOVE gt_mat-type  TO gt_final-type.
      Condition description
    CASE gt_mat-type  .
    when  'N'.
    move  'New'  to gt_final-condes.
    when  'B'.
    move 'Block'   to gt_final4-condes.
    ENDCASE.
    ENDLOOP.
    please let me know whats the problem i above code and how to solve.
    thanks in advance.

    Hi,
    The only solution for this could be to debug the program and check if the coresponding values are populated and available. You could also try to replace the CASE statement with a simple IF statement and check if its working.
    LOOP AT gt_mat.
    MOVE gt_mat-type TO gt_final-type.
    * Condition description
    IF gt_mat-type = 'N'.
    gt_final-condes = 'New'.
    elseif gt_mat-type = 'B'.
    gt_final-condes ='Block'.
    append gt_final.
    clear gt_final.
    ENDIF.
    ENDLOOP.
    Also make sure the case of the value in gt_mat-type matches with the condition
    Regards,
    Vikranth

  • Problem in using aggregate functions inside case statement

    Hi All,
    I am facing problem while using aggregate functions inside case statement.
    CASE WHEN PSTYPE='S' THEN MAX(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ELSE SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) END,
    how can I achieve above requirement ? Con anyone help me.
    Thanks and Regards
    DG

    Hi All,
    Below is my query:
            SELECT
            CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT
            ELSE POS.PACCT || '-' || DECODE(POS.SYSTEMCODE,'GMI1','1', 'GMI2','2', 'GMI3','4', 'GMI4','3', '0') ||POS.PFIRM|| NVL(POS.POFFIC,'000') END,
            CASE WHEN p_reportid IN ('POS_RV_SN','POS_PB') THEN POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-')
            ELSE POS.PFIRM||POS.POFFIC||POS.PACCT||POS.PCUSIP||DECODE(POS.PBS,1,'+',2,'-') END,POS.SYSTEMCODE,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,POS.PEXCH||DECODE(POS.PSUBEX,'<NULL>',''),
            POS.PCURSY,
            CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) END ,
            NVL(POS.PSUBTY,'F') ,POS.PSTRIK,*SUM(DECODE(POS.PBS,1,ABS(POS.PPRTQ),0)) ,SUM(DECODE(POS.PBS,2,ABS(POS.PPRTQ),0))* ,
            POS.PCLOSE,SUM(POS.PMKVAL) ,
            TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
            POS.UBS_ID,POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER ,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,TO_CHAR(POS.BUSINESS_DATE,'YYYYMMDD'),
            POS.SOURCE_GMI_LIB,
            --DECODE(POS.SYSTEMCODE,'GMI1','euro','GMI2','namr','GMI3','aust','GMI4','asia','POWERBASE','aust','SINACOR','namr',POS.SYSTEMCODE),
            DECODE(p_reportid,'RVPOS_SING','euro','RVPOS_AUSTDOM','aust','RVPOS_AUSTEOD','euro','RVPOS_GLBLAPAC','asia','POS_RV_SN','namr','POS_PB','aust',POS.SYSTEMCODE),
            POS.RIC,
            CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
            DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
            CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
            CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
            NVL(C.SSECID,POS.PCUSIP),
            NULL,
            POS.PYSTMV,
            POS.PMINIT,
            POS.PEXPDT,
            CASE WHEN POS.PSUBTY='S' THEN  SUBSTR(C.ZDATA2,77,1) ELSE NULL END,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL,
            NULL
            FROM POSITIONS_WRK POS LEFT OUTER JOIN
            (SELECT * FROM CDS_PRODUCTS CP INNER JOIN FUTURE_MASTER FM ON
            (CP.STRXCH=FM.ZEXCH AND CP.SFC=FM.ZFC AND CP.BUSINESS_DATE = FM.BUSINESS_DATE )) C ON POS.PCUSIP = C.SCUSIP
            AND NVL(POS.PCUSP2,'X') = NVL(C.SCUSP2,'X')
            WHERE
            POS.PEXCH NOT IN ('A1','A2','A3','B1','B3','C2','D1','H1','K1','L1','M1','M3','P1','S1')
            AND (POS.PSBCUS IS NOT NULL OR POS.PCTYM IS NOT NULL OR POS.PSTYPE ='S')
            AND POS.BUSINESS_DATE = run_date_char
            GROUP BY
            POS.UBS_ID,POS.SYSTEMCODE,POS.RECIPIENTCODE,POS.BUSINESS_DATE,POS.PACCT,POS.PFIRM,POS.POFFIC,POS.PCUSIP,POS.PBS,CASE WHEN POS.PSTYPE='S' THEN POS.PSYMBL ELSE POS.PFC END,
            POS.PEXCH,POS.PSUBEX,POS.PCURSY,
            CASE WHEN POS.PSBCUS IS NULL THEN SUBSTR(POS.PCTYM,5,2) || SUBSTR(POS.PCTYM,1,4) ELSE POS.PSBCUS || SUBSTR(POS.PCTYM,5,2)  || SUBSTR(POS.PCTYM,1,4) END,
            NVL(POS.PSUBTY,'F') ,POS.PSTRIK,POS.PCLOSE,TO_CHAR(CASE WHEN INSTR(POS.PUNDCP,'.') > 0 OR LENGTH(POS.PUNDCP) < 15 THEN POS.PUNDCP ELSE TO_CHAR(TO_NUMBER(POS.PUNDCP) / 100000000) END),
            POS.BBG_EXCHANGE_CODE,POS.BBG_TICKER,POS.BBG_YELLOW_KEY,POS.PPCNTY,POS.PMULTF,POS.PSUBTY,POS.SOURCE_GMI_LIB,RIC,
            CASE WHEN PSUBTY = 'S' THEN POS.TYPE ELSE NULL END,
            DECODE(POS.UBS_ID,NULL,POS.PCUSP2,POS.ISIN),POS.UNDERLYING_BBG_TICKER,POS.UNDERLYING_BBG_EXCHANGE,POS.PRODUCT_CLASSIFICATION,
            CASE WHEN PSUBTY = 'S' THEN POS.PSDSC2 ELSE NULL END,
            CASE WHEN PSUBTY = 'S' THEN C.SSDSC3 ELSE NULL END,
            NVL(C.SSECID,POS.PCUSIP),
            POS.PYSTMV,
            POS.PMINIT,
            POS.PEXPDT,
            CASE WHEN PSUBTY = 'S'  THEN  SUBSTR(C.ZDATA2,77,1) ELSE NULL END;Now, could you plz help me in replacing the bold text in the query with the requirement.
    Thanks and Rgds
    DG
    Edited by: BluShadow on 16-May-2011 09:39
    added {noformat}{noformat} tags.  Please read: {message:id=9360002} for details on how to post code/data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem to identify values in a case statement.

    Hi Friends,
    Total number of records in my report should be divided by 5 and to be alloted into 5 grades in Grade column.
    This is what I have done so far in my report with following layout.
    S.No - Col A - Col B - Col C - Grade ( Colums A,B,C will be hidden in Report)
    *****Column C will have only 5 values at max ( 0.0, 0.2, 0.4, 0.6, 0.8).The below example is for 6 records in a report.The same will be applied for 7,8,9,10 records.
    In column A: MAX(cast(RCOUNT(1) AS DOUBLE))/5 ( Ex : 6/5 = 1.2)
    In Column B: Truncate(MAX(cast (RCOUNT(1) as double)/5), 0) ( Ex : 6/5 = 1.0)
    In Column C: Col A- Col B ( EX:1.2 - 1.0 =0.2)
    (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0))
    Now In Grade coulum I want to use this column C to Grade the records with case statements in it.
    I am trying to use the following case statement for Grade Coulmn
    Case
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.0 then .........
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.2 then .............
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.4 then .............
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.6 then ........
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.8 then .....
    end
    Case statement works gud for 0.0 but not for other 4 values.
    It is unable to identify other 4values.
    Please tell me, how can I make case statement work for all values in above scenario.
    Thanks in Advance,
    Varsha.
    Edited by: Varsha on Nov 28, 2010 6:23 PM

    In column A: MAX(cast(RCOUNT(1) AS DOUBLE))/5 ( Ex : 6/5 = 1.2)
    In Column B: Truncate(MAX(cast (RCOUNT(1) as double)/5), 0) ( Ex : 6/5 = 1.0)
    In Column C: Col A- Col B ( EX:1.2 - 1.0 =0.2)
    (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0))Change the formula a bit by adding the by dim value for the MAX column.
    Column A: MAX(cast(RCOUNT(1) AS DOUBLE) by DimTable.Column)/5
    Column B: Truncate(MAX(cast (RCOUNT(1) as double) by DimTable.Column)/5, 0)
    Column C: MAX(cast(RCOUNT(1) AS DOUBLE) by DimTable.Column)/5 - Truncate(MAX(cast (RCOUNT(1) as double) by DimTable.Column)/5, 0)
    now write a case statement on top column c, based on your logic every 5th record will have a value 0.0
    Note: Dimtable.column is the table.column for which the row count is taken.
    Thanks,
    Vino

  • Problem with Case statement

    I friends,
    I am using a case statement for a number field like this
    case when (customer_no is null or customer_no ='') then t.customer_no else gv.customer_no end as customer_no
    When i complie this i get an errror ORa-00932 inconsistent data types expected char got number....
    when i remove the case statement the query runs fine so i am sure its the case statement thats wrong here..Am i checking it the wrong way...
    Thank you in advance

    874167 wrote:
    I friends,
    I am using a case statement for a number field like this
    case when (customer_no is null or customer_no ='') then t.customer_no else gv.customer_no end as customer_no
    When i complie this i get an errror ORa-00932 inconsistent data types expected char got number....
    when i remove the case statement the query runs fine so i am sure its the case statement thats wrong here..Am i checking it the wrong way...
    Thank you in advancewith Oracle strings are enclosed in single quote marks
    so Oracle is confused & unhappy with line below
    customer_no =''
    since CUSTOMEER_NO is a NUMBER
    why do you compare number to a string?

  • CASE statement... problem using it... what have I done to deserve this?

    I'm trying to use a CASE statement in Ora 8.1.7 (with compatible
    set to 8.1.0) and am finding that I cannot compile the
    procedure.
    I'm using the CASE statement in a call to a procedure...
    insert_addr (p_id_number => v_id_number,
    p_addr_type => v_addr_type,
    p_addr_status => v_addr_status,
    p_addr_pref_ind => v_pref_addr_ind,
    p_date_modified =>
    (CASE
    WHEN cmf_rec.hadoc = cnv_constants.nov17_1958
    THEN cmf_rec.doe
    ELSE cmf_rec.hadoc
    END)
    I'm getting "PLS-00103 Encountered the symbol "CASE" when
    expecting one of the following..." error msg when compiling.
    What have I done wrong? Syntax error? Should I change the
    compatible parameter?
    Thanks.

    You can actually use the CASE statement in Pl/Sql, though not like in SqlPlus.
    You have to use dynamic Sql.
    Example
    create or replace procedure test_case1 is
    v_sql varchar2(4000);
    begin
    v_sql := 'update case_test set qual_rule = '||
             '(case '||
             ' when dob < ''01-jan-1902'' then ''100+'' '||
             ' when dob between ''01-jan-1902'' and ''31-dec-1912'' then ''90-99'' '||
             ' when dob between ''01-jan-1912'' and ''31-jan-1932'' then ''70-89'' '||
             ' when dob between ''01-jan-1932'' and ''31-jan-1952'' then ''50-69'' '||
             ' when dob between ''01-jan-1952'' and ''31-jan-1972'' then ''30-49'' '||
             ' when dob between ''01-jan-1972'' and ''31-jan-1984'' then ''< 30'' '||
             ' else ''under age'' '||
             ' end ) ';
    execute immediate v_sql;
    commit;
    end test_case1;

  • Problem w/ Case Statement and Video Capture

    Hey!
    I've got a question about a topic which seems pretty trivial, but has been giving me quite the trouble for some time now. I was hoping that someone on this forum would be able to help me catch and fix my mistake.
    Basically what I'm trying to do is capture video from a camera, run some video analysis for a certain duration, and store the raw footage for that same duration in an avi file. I'm using IMAQdx and a Logitech C920 camera to gather video. When I run the program, I want there to be an output of the raw video on the front panel. When I then hit a button, I would like the camera to save a .avi file of the video for a set number of frames and concurrently run some analysis and display the results on another display on the front panel. The purpose of the raw footage in the .avi file is to be able to run the analysis again at a later date.
    I've attached both a screenshot and the .vi file to this post. When I run the current script, I'm confronted with one of two possible errors (not sure why they're different from time to time). The Video Acquisition Block either "Time Out"s or the Write to AVI block issues an incompatible image type error. The reason why I'm baffled by this is because when I take it out of the case statement and have it run with the rest of the program, the .avi file is generated accurately and stored.
    Any help would be greatly appreciated. Thanks!
    Attachments:
    Script Image.png ‏39 KB
    11_30_12 TrackVIEW.vi ‏271 KB

    Greetings, 
    Would the time out error happen every time you run the VI? In addition, do these errors have a code?
    I was able to replicate the issue and initially believe that it might be that we are simultaneously opening two sessions to the same camera. Could you simply take a finite number of images from the first acquisition and chain the second one via sequence structure? It would limit the viewer to only view the video on the other Image Display during saving the AVI, but it might be worthwhile looking into. 
    It might also be worthwhile to consider enquewing a certain number of images whenever the button is pressed, but that would require some more programming logic.
    Cordially;
    Simon P.
    National Instruments
    Applications Engineer

  • CASE not found while executing CASE statement on Submit Form

    Hi to all APEX users and developers.
    I have several APEX applications and they are all working well, but recently I got one strange exception when I try to submit page:
    Session: Fetch session header information
    ...metadata, fetch page info
    ...Validate item page affinity.
    ...Validate hidden_protected items.
    Add error onto error stack
    ...Error data:
    ......message: Error processing request.
    ......additional_info: ORA-06592: CASE not found while executing CASE statement
    ......display_location: ON_ERROR_PAGE
    ......is_internal_error: true
    ......apex_error_code: APEX.UNHANDLED_ERROR
    ......ora_sqlcode: -6592
    ......ora_sqlerrm: ORA-06592: CASE not found while executing CASE statement
    .....error_backtrace: ORA-06512: at "APEX_040100.WWV_FLOW", line 9273
    ......component.type: APEX_APPLICATION_AUTH
    ......component.id: 41350431648668800
    ......component.name: MNRFR
    ...Show Error on Error Page
    ......Performing rollback
    Processes - point: AFTER_ERROR_HEADER
    Processes - point: BEFORE_ERROR_FOOTER
    End Page Processinga
    Page has more than 120 items (most of them are hidden), so my first thought is that page has problem with posting so many items, but APEX error message doesn't hel me at all. Any help would be very appreciated :)
    Almir

    Hi Almir,
    actually it is the 100 page item limit. See (http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/limits.htm)
    I also had a look into the source code and the code at the position where the error gets raised only supports 100 page items.
    Can you have a look into the generated HTML code and look if you have a page items which is mapped to p_t101 or a higher number ?
    I will file a bug to show a better error message.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • How can you change a drop down menu's selection in a case statement?

    Hi,
    I am trying to an array finding vi. This VI will take an existing xml file and after the user has selected his/her equipment, input, output, and frequency it will put all of those options into a string and search the xml file for that exact array name and display it on an output screen. The problem I am having is that my input and outputs selection needs to be a little different depending upon the equipment selected. I thought that I could use a case statement to change the input and output selectable options, but I have run into many snags with it. For one everytime I place a new Input and Output drop down menu in the case statement it wants to place a new one in the front panel (I only want one input and output not three I have two inputs and outputs hidden right now). I believe I am using the case statement wrong... Can anyone help change my input and output selectable options depending upon the equipment selected. Attached is my xml file, Array Find.vi (the original one), and Array Find_Test.vi (this is the one I am trying to modify).
    Thanks,
    dlovell
    Solved!
    Go to Solution.
    Attachments:
    Find Array.zip ‏126 KB

    Hi dlovell,
    There are 2 key things I'd recommend for the code - using property nodes to edit the strings in the combo boxes.  Something like the following snippet:
    Also, check your CPU in task manager when running the code.  It will eat a whole core of your machine (25% quad core, 50% dual, 100% single) - that is because you are running the while loop and polling the control as fast as Windows will allow you to.  Using Event Structures is a much more efficient way of working in this example.
    Check out the MOD attached 
    Regards,
    Peter D
    Attachments:
    MOD_Find Array.vi ‏28 KB

  • CASE STATEMENTS AND CASE EXPRESSIONS IN ORACLE9I PL/SQL

    제품 : PL/SQL
    작성날짜 : 2001-11-13
    CASE STATEMENTS AND CASE EXPRESSIONS IN ORACLE9I PL/SQL
    =======================================================
    PURPOSE
    아래의 자료는 Case 문에서 oracle 8.1.7과 Oracle 9i의 New Feature로 8.1.7에서는
    sqlplus 에서만 가능했고, 9i 부터는 pl/sql 까지 가능하다.
    Explanation
    1. Oracle 8.1.7 Feature
    Oracle 8.1.7 에서 Case 문은 Decode 문과 유사하지만, 기존의 decode 문을 쓰는 것보다
    더 많은 확장성과 Logical Power와 좋은 성능을 제공한다. 주로 나이와 같이 category 별로
    나눌때 주로 사용하고 Syntex는 아래와 같다.
    CASE WHEN <cond1> THEN <v1> WHEN <cond2> THEN <v2> ... [ELSE <vn+1> ] END
    각각의 WHEN...THEN 절의 argument 는 255 까지 가능하고 이 Limit를 해결하려면
    Oracle 8i Reference를 참조하면 된다.
    The maximum number of arguments in a CASE expression is 255, and each
    WHEN ... THEN pair counts as two arguments. To avoid exceeding the limit of 128 choices,
    you can nest CASE expressions. That is expr1 can itself be a CASE expression.
    Case Example : 한 회사의 모든 종업원의 평균 봉급을 계산하는데 봉급이 $2000보다 작은경우
    2000으로 계산을 하는 방법이 pl/sql을 대신하여 case function을 사용할 수 있다.
    SELECT AVG(CASE when e.sal > 2000 THEN e.sal ELSE 2000 end) FROM emp e;
    Case Example : 나이를 column으로 가지고 있는 customer table을 예로 들어보자.
    SQL> SELECT
    2 SUM(CASE WHEN age BETWEEN 70 AND 79 THEN 1 ELSE 0 END) as "70-79",
    3 SUM(CASE WHEN age BETWEEN 80 AND 89 THEN 1 ELSE 0 END) as "80-89",
    4 SUM(CASE WHEN age BETWEEN 90 AND 99 THEN 1 ELSE 0 END) as "90-99",
    5 SUM(CASE WHEN age > 99 THEN 1 ELSE 0 END) as "100+"
    6 FROM customer;
    70-79 80-89 90-99 100+
    4 2 3 1
    1 SELECT
    2 (CASE WHEN age BETWEEN 70 AND 79 THEN '70-79'
    3 WHEN age BETWEEN 80 and 89 THEN '80-89'
    4 WHEN age BETWEEN 90 and 99 THEN '90-99'
    5 WHEN age > 99 THEN '100+' END) as age_group,
    6 COUNT(*) as age_count
    7 FROM customer
    8 GROUP BY
    9 (CASE WHEN age BETWEEN 70 AND 79 THEN '70-79'
    10 WHEN age BETWEEN 80 and 89 THEN '80-89'
    11 WHEN age BETWEEN 90 and 99 THEN '90-99'
    12* WHEN age > 99 THEN '100+' END)
    SQL> /
    AGE_G AGE_COUNT
    100+ 1
    70-79 4
    80-89 2
    90-99 3
    Example
    2. Oracle 9i Feature
    Oracle 9i부터는 pl/sql에서도 case문을 사용할 수 있으면 이것은
    복잡한 if-else 구문을 없애고, C언어의 switch문과 같은 기능을 한다.
    아래의 9i pl/sql Sample 및 제약 사항을 보면 아래와 같다.
    Sample 1:
    A simple example demonstrating the proper syntax for a case
    statement
    using a character variable as the selector. See the section entitled
    'Restrictions' at the end of this article for details on which PLSQL
    datatypes may appear as a selector in a case statement or
    expression.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    achar char(1) := '&achar';
    begin
    case achar
    when 'A' then dbms_output.put_line('The description was Excellent');
    when 'B' then dbms_output.put_line('The description was Very Good');
    when 'C' then dbms_output.put_line('The description was Good');
    when 'D' then dbms_output.put_line('The description was Fair');
    when 'F' then dbms_output.put_line('The description was Poor');
    else dbms_output.put_line('The description was No such Grade');
    end case;
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 2:
    A simple example demonstrating the proper syntax for a case
    expression
    using a character variable as the selector. See the section entitled
    'Restrictions' at the end of this article for details on which PLSQL
    datatypes may appear as a selector in a case statement or
    expression.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    achar char(1) := '&achar';
    description varchar2(20);
    begin
    description :=
    case achar
    when 'A' then 'Excellent'
    when 'B' then 'Very Good'
    when 'C' then 'Good'
    when 'D' then 'Fair'
    when 'F' then 'Poor'
    else 'No such grade'
    end;
    dbms_output.put_line('The description was ' || description);
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    NOTE: The above simple samples demonstrate two subtle differences in the
    syntax
    required for case statements and expressions.
    1) A case STATEMENT is terminated using the 'end case' keywords; a
    case
    EXPRESSION is terminated using only the 'end' keyword.
    2) Each item in a case STATEMENT consists of one or more
    statements, each
    terminated by a semicolon. Each item in a case expression
    consists of
    exactly one expression, not terminated by a semicolon.
    Sample 3:
    Sample 1 demonstrates a simple case statement in which the selector
    is
    compared for equality with each item in the case statement body.
    PL/SQL
    also provides a 'searched' case statement as an alternative; rather
    than
    providing a selector and a list of values, each item in the body of
    the
    case statement provides its own predicate. This predicate can be any
    valid boolean expression, but only one case will be selected.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    achar char(1) := '&achar';
    begin
    case
    when achar = 'A' then dbms_output.put_line('The description was
    Excellent');
    when achar = 'B' then dbms_output.put_line('The description was Very
    Good');
    when achar = 'C' then dbms_output.put_line('The description was
    Good');
    when achar = 'D' then dbms_output.put_line('The description was
    Fair');
    when achar = 'F' then dbms_output.put_line('The description was
    Poor');
    else dbms_output.put_line('The description was No such Grade');
    end case;
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 4:
    This sample demonstrates the proper syntax for a case expression of
    the
    type discussed in Sample 3 above.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    achar char(1) := '&achar';
    description varchar2(20);
    begin
    description :=
    case
    when achar = 'A' then 'Excellent'
    when achar = 'B' then 'Very Good'
    when achar = 'C' then 'Good'
    when achar = 'D' then 'Fair'
    when achar = 'F' then 'Poor'
    else 'No such grade'
    end;
    dbms_output.put_line('The description was ' || description);
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 5:
    This sample demonstrates the use of nested case statements. It is
    also
    permissable to nest case expressions within a case statement (though
    it
    is not demonstrated here), but nesting of case statements within a
    case
    expression is not possible since statements do not return any value.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    anum1 number := &anum1;
    anum2 number := &anum2;
    answer number;
    begin
    case anum1
    when 1 then case anum2
    when 1 then answer := 10;
    when 2 then answer := 20;
    when 3 then answer := 30;
    else answer := 999;
    end case;
    when 2 then case anum2
    when 1 then answer := 15;
    when 2 then answer := 25;
    when 3 then answer := 35;
    else answer := 777;
    end case;
    else answer := 555;
    end case;
    dbms_output.put_line('The answer is ' || answer);
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 6:
    This sample demonstrates nesting of case expressions within another
    case
    expression. Note again the absence of semicolons to terminate both
    the
    nested case expression and the individual cases of those
    expressions.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    declare
    anum1 number := &anum1;
    anum2 number := &anum2;
    answer number;
    begin
    answer :=
    case anum1
    when 1 then case anum2
    when 1 then 10
    when 2 then 20
    when 3 then 30
    else 999
    end
    when 2 then case anum2
    when 1 then 15
    when 2 then 25
    when 3 then 35
    else 777
    end
    else 555
    end;
    dbms_output.put_line('The answer is ' || answer);
    end;
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Although PL/SQL anonymous blocks have been used in all of the examples
    so far,
    case statements and expressions can also be used in procedures,
    functions, and
    packages with no changes to the syntax.
    The following samples are included for completeness and demonstrate the
    use of
    case statements and/or expressions in each of these scenarios.
    Sample 7:
    This sample demonstrates use of a case statement in a stored
    procedure.
    Note that this sample also demonstrates that it is possible for each
    of
    the items in the case body to consist of more than one statement.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    create or replace procedure testcasestmt ( anum IN number ) is
    begin
    case
    when anum = 1 then dbms_output.put_line('The number was One');
    dbms_output.put_line('In case 1');
    when anum = 2 then dbms_output.put_line('The number was Two');
    dbms_output.put_line('In case 2');
    when anum = 3 then dbms_output.put_line('The number was Three');
    dbms_output.put_line('In case 3');
    when anum = 4 then dbms_output.put_line('The number was Four');
    dbms_output.put_line('In case 4');
    when anum = 5 then dbms_output.put_line('The number was Five');
    dbms_output.put_line('In case 5');
    else dbms_output.put_line('The description was Invalid input');
    dbms_output.put_line('In the else case');
    end case;
    end;
    exec testcasestmt(&anum);
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 8:
    This sample demonstrates the use of a case statement in a stored
    package.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    create or replace package testpkg2 is
    procedure testcasestmt ( anum IN number );
    function testcasestmt_f ( anum IN number ) return number;
    end testpkg2;
    create or replace package body testpkg2 is
    procedure testcasestmt ( anum IN number ) is
    begin
    case
    when anum = 1 then dbms_output.put_line('The number was One');
    dbms_output.put_line('In case 1');
    when anum = 2 then dbms_output.put_line('The number was Two');
    dbms_output.put_line('In case 2');
    when anum = 3 then dbms_output.put_line('The number was Three');
    dbms_output.put_line('In case 3');
    when anum = 4 then dbms_output.put_line('The number was Four');
    dbms_output.put_line('In case 4');
    when anum = 5 then dbms_output.put_line('The number was Five');
    dbms_output.put_line('In case 5');
    else dbms_output.put_line('The description was Invalid input');
    dbms_output.put_line('In the else case');
    end case;
    end;
    function testcasestmt_f ( anum IN number ) return number is
    begin
    case
    when anum = 1 then dbms_output.put_line('The number was One');
    dbms_output.put_line('In case 1');
    when anum = 2 then dbms_output.put_line('The number was Two');
    dbms_output.put_line('In case 2');
    when anum = 3 then dbms_output.put_line('The number was Three');
    dbms_output.put_line('In case 3');
    when anum = 4 then dbms_output.put_line('The number was Four');
    dbms_output.put_line('In case 4');
    when anum = 5 then dbms_output.put_line('The number was Five');
    dbms_output.put_line('In case 5');
    else dbms_output.put_line('The description was Invalid input');
    dbms_output.put_line('In the else case');
    end case;
    return anum;
    end;
    end testpkg2;
    exec testpkg2.testcasestmt(&anum);
    variable numout number
    exec :numout := testpkg2.testcasestmt_f(&anum);
    print numout
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    Sample 9:
    This sample demonstrates the use of a case expression in a stored
    package.
    - - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - -
    set serveroutput on
    create or replace package testpkg is
    procedure testcase ( anum IN number );
    function testcase_f ( anum IN number ) return number;
    end testpkg;
    create or replace package body testpkg is
    procedure testcase ( anum IN number ) is
    anumber number := anum;
    anothernum number;
    begin
    anothernum :=
    case
    when anumber = 1 then anumber + 1
    when anumber = 2 then anumber + 2
    when anumber = 3 then anumber + 3
    when anumber = 4 then anumber + 4
    when anumber = 5 then anumber + 5
    else 999
    end;
    dbms_output.put_line('The number was ' || anothernum);
    end;
    function testcase_f ( anum IN number ) return number is
    anumber number := anum;
    anothernum number;
    begin
    anothernum :=
    case
    when anumber = 1 then anumber + 1
    when anumber = 2 then anumber + 2
    when anumber = 3 then anumber + 3
    when anumber = 4 then anumber + 4
    when anumber = 5 then anumber + 5
    else 999
    end;
    dbms_output.put_line('The number was ' || anothernum);
    return anothernum;
    end;
    end testpkg;
    variable numout number
    exec testpkg.testcase(&anum);
    exec :numout := testpkg.testcase_f(&anum);
    print numout
    - - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - -
    제약 사항
    다음의 databasetype은 case 문에서 지원되지 않는다.
    BLOB
    BFILE
    VARRAY
    Nested Table
    PL/SQL Record
    PL/SQL Version 2 tables (index by tables)
    Object type (user-defined type)
    All of these types except for object types face a similar restriction
    even for if statements (i.e. they cannot be compared for equality directly) so this is unlikely to change for these types. Lack of support for object types is simply an implementation restriction which may be relaxed in future releases.
    Reference Ducumment
    Oracle 8.1.7 Manual
    NOTE:131557.1

    I have done the following code but doesn't
    like the statement of - "case(butNext)". What do you mean "doesn't like" -- did you get an error message?
    I'm guessing it won't compile because you're trying to switch on a Button.
    I tried something
    like "g.fillOval(100,50,70,90, BorderLayout.NORTH)"...no that doesn't make sense. You only use BorderLayout.NORTH when you're adding components to a BorderLayout layout manager. An oval is not a component and fillOval isn't adding a component and Graphics is not a Panel or layout manager.
    Would appreciate it if someone could tell me how to position
    shapes using the graohic method. I think the problem is that you're confusing shapes with components.

  • Should I use a CASE statement to accomplish or something else

    So I have the following query right now
    select *
        --bulk collect into possession_leaders
        from
               select    distinct
                         opt.team_id,
                         sch.game_code,
                         sch.game_code_1032,
                         sch.home_team_id_1032,
                         sch.home_team_id,
                         sch.home_team_name,
                         sch.home_team_nickname,
                         sch.home_team_abbrev,
                         sch.away_team_id_1032,
                         sch.away_team_id,
                         sch.away_team_name,
                         sch.away_team_nickname,
                         sch.away_team_abbrev,
                         opt.possession,
                         rank () over (order by possession desc) as rankings_order
              from 
                       customer_data.cd_soccer_schedule sch,
                       soccer.soccer_optical_team_gm_stats opt
              where    sch.game_code = opt.game_code
              and      sch.season_id = 200921
              and      opt.possession is not null
              order by rankings_order asc
            )It outputs the following (Sorry for it being so cramped together):
    **Note: Columns are in the same order as the query, I didn't post the column names b/c everything would look even sloppier then it does
    1     5358     870986     2009050606     6     5359     Kansas City     Wizards     KC     5     5358     D.C.     United     DC     69.5%     1
    2     5354     870945     2009040501     1     5354     Chicago     Fire     Chi     10     5362     New York     Red Bulls     RB     58.1%     2
    3     5721     870983     2009050211     11     5363     San Jose     Earthquakes     SJ     17     5721     Chivas USA          Chv     56%     3
    4     5360     870984     2009050207     7     5360     Los Angeles     Galaxy     LA     10     5362     New York     Red Bulls     RB     55.6%     4
    5     5361     870961     2009041705     5     5358     D.C.     United     DC     9     5361     New England     Revolution     NE     55.4%     5
    6     5362     870988     2009050810     10     5362     New York     Red Bulls     RB     11     5363     San Jose     Earthquakes     SJ     50.1%     6
    7     5363     870988     2009050810     10     5362     New York     Red Bulls     RB     11     5363     San Jose     Earthquakes     SJ     49.9%     7
    8     5358     870961     2009041705     5     5358     D.C.     United     DC     9     5361     New England     Revolution     NE     44.6%     8
    9     5362     870984     2009050207     7     5360     Los Angeles     Galaxy     LA     10     5362     New York     Red Bulls     RB     44.4%     9
    10     5363     870983     2009050211     11     5363     San Jose     Earthquakes     SJ     17     5721     Chivas USA          Chv     44%     10
    11     5362     870945     2009040501     1     5354     Chicago     Fire     Chi     10     5362     New York     Red Bulls     RB     41.9%     11
    12     5359     870986     2009050606     6     5359     Kansas City     Wizards     KC     5     5358     D.C.     United     DC     30.5%     12What i'm trying to do is basically have the output formated so that when the team_id column matches the either the home_team_id or away_team_id colum i want the following columns to be renamed as:
    so if team_id = home_team_id for example then I want the following...
    sch.home_team_id_1032 as team_code_1032,
    sch.home_team_id as team_code,
    sch.home_team_name as team_name,
    sch.home_team_nickname as team_nickname,
    sch.home_team_abbrev as team_abbrev
    and then the away team columns would be...
    sch.away_team_id_1032 as opp_team_code_1032,
    sch.away_team_id as opp_team_code,
    sch.away_team_name as opp_team_name,
    sch.away_team_nickname as opp_team_nickname,
    sch.away_team_abbrev as opp_team_abbrev
    and same thing vice versa if the team_id column matches the away_team_id
    How is the best way to go about this? W/a case statement? and if so can someone please post the logic/

    Hi,
    user652714 wrote:
    So I have the following query right now
    select *
    --bulk collect into possession_leaders
    from
    select    distinct
    opt.team_id,
    sch.game_code,
    sch.game_code_1032,
    sch.home_team_id_1032,
    sch.home_team_id,
    sch.home_team_name,
    sch.home_team_nickname,
    sch.home_team_abbrev,
    sch.away_team_id_1032,
    sch.away_team_id,
    sch.away_team_name,
    sch.away_team_nickname,
    sch.away_team_abbrev,
    opt.possession,
    rank () over (order by possession desc) as rankings_order
    from 
    customer_data.cd_soccer_schedule sch,
    soccer.soccer_optical_team_gm_stats opt
    where    sch.game_code = opt.game_code
    and      sch.season_id = 200921
    and      opt.possession is not null
    order by rankings_order asc
    )It outputs the following (Sorry for it being so cramped together):
    **Note: Columns are in the same order as the query, I didn't post the column names b/c everything would look even sloppier then it doesAre you sure?
    The 6th column in the query is home_team name; the 6th column of the output has values like 5359 and 5354. Did you perhaps duplicate the rankings_iorder column at the beginning of the results?
    Why don't you simplify the problem. Instead of 15 or 16 columns, 10 of which are twins (5 pairs of 2 columns), why don't you post a problem with 6 columns, 4 of which are twins? Pick short columns, such as home_team_abbrev rather than home_team_name.
    Adding the other columns later should be easy; merely a matter of coping one of the columns ion the solution.
    Whenever you have a problem, post some sample data and the results you want from that data.
    In this case, the sample data can be about 6 columns from the result set below. I'll bet you can make a good sample set with fewer than 12 rows, also.
    1     5358     870986     2009050606     6     5359     Kansas City     Wizards     KC     5     5358     D.C.     United     DC     69.5%     1
    2     5354     870945     2009040501     1     5354     Chicago     Fire     Chi     10     5362     New York     Red Bulls     RB     58.1%     2
    3     5721     870983     2009050211     11     5363     San Jose     Earthquakes     SJ     17     5721     Chivas USA          Chv     56%     3
    4     5360     870984     2009050207     7     5360     Los Angeles     Galaxy     LA     10     5362     New York     Red Bulls     RB     55.6%     4
    5     5361     870961     2009041705     5     5358     D.C.     United     DC     9     5361     New England     Revolution     NE     55.4%     5
    6     5362     870988     2009050810     10     5362     New York     Red Bulls     RB     11     5363     San Jose     Earthquakes     SJ     50.1%     6
    7     5363     870988     2009050810     10     5362     New York     Red Bulls     RB     11     5363     San Jose     Earthquakes     SJ     49.9%     7
    8     5358     870961     2009041705     5     5358     D.C.     United     DC     9     5361     New England     Revolution     NE     44.6%     8
    9     5362     870984     2009050207     7     5360     Los Angeles     Galaxy     LA     10     5362     New York     Red Bulls     RB     44.4%     9
    10     5363     870983     2009050211     11     5363     San Jose     Earthquakes     SJ     17     5721     Chivas USA          Chv     44%     10
    11     5362     870945     2009040501     1     5354     Chicago     Fire     Chi     10     5362     New York     Red Bulls     RB     41.9%     11
    12     5359     870986     2009050606     6     5359     Kansas City     Wizards     KC     5     5358     D.C.     United     DC     30.5%     12What i'm trying to do is basically have the output formated so that when the team_id column matches the either the home_team_id or away_team_id colum i want the following columns to be renamed as:
    so if team_id = home_team_id for example then I want the following...
    sch.home_team_id_1032 as team_code_1032,
    sch.home_team_id as team_code,
    sch.home_team_name as team_name,
    sch.home_team_nickname as team_nickname,
    sch.home_team_abbrev as team_abbrev
    and then the away team columns would be...
    sch.away_team_id_1032 as opp_team_code_1032,
    sch.away_team_id as opp_team_code,
    sch.away_team_name as opp_team_name,
    sch.away_team_nickname as opp_team_nickname,
    sch.away_team_abbrev as opp_team_abbrev
    and same thing vice versa if the team_id column matches the away_team_idSorry, column names have to stay the same throughout the query. This is a very unusual request, and it's hard for me to imagine what you really want.
    You miight be able to do a UNION and add rows that look like column headings.
    No kidding, you have to post the results you want.
    No matter how clear an idea you have of what those resutls should be, no one else knows, and it's much easier to post the correct results than to accurately describe them.

Maybe you are looking for

  • Outbound Delivery without Manufacturing date

    Hi Guys, I have activated SLED in Article master.(We are using SAP IS Retail, ECC 6.00) At the time of GRN, users have entered manufacturing date to check remaining shelf life for an article. I have made following customization (using transaction cod

  • 9iAS Integration -- processing batches?

    I'm trying to make sense of the 9iAS Integration product based on all the downloadable materials. I understand that the product is essentially message based, but is it possible to use the product to process batches of data? For example, can I use the

  • What is the difference between infocube and fact table?

    hi bw gurus, what is the difference between infocube and fact table? thanks in advance bye

  • Adobe Reader Error Pop Up

    I get this error message saying to accept the end user licensing agreement of Adobe Reader but when I went to download it, a caption said that by downloading Adobe Reader you automatically accept the licensing agreement. If i automatically accept it

  • Lightroom Image Looks Different than in Windows Viewer/CS5/etc.

    I've seen this discussed elsewhere, but I believe the nature of my issue may be a bit different, so please excuse the repeat inquiry. I'm currently using Lightroom 3 on a 17' Samsung Syncmaster 920NW on two different desktops. The hardware configurat