Optimize SQL with case-when-other

Hello

try to categorize DateValue into 3 groups
1. effective: current month
2. for a YEAR: between January and last month of the current year
3. for a YEAR: between January and last month of the last year

I have a feeling that my SQL could be much shorter and faster. I would be grateful for professional advice...

-case when TO_NUMBER ((TO_CHAR (DOCUMENT_TIMESTAMP, 'YYYY') |)) To_char (DOCUMENT_TIMESTAMP, 'MM'))) = TO_NUMBER (TO_CHAR (sysdate, 'YYYY') |) To_char (sysdate, 'MM'))
can 'real '.
-FOR A YEAR
When TO_NUMBER ((TO_CHAR (DOCUMENT_TIMESTAMP, 'YYYY') |)) To_char (DOCUMENT_TIMESTAMP, 'MM'))) between TO_NUMBER (TO_CHAR (sysdate, 'YYYY') |) (' 01') and TO_NUMBER (TO_CHAR (sysdate, 'YYYY') |) To_char (sysdate, 'MM'))-1
then "CDA".
-PYTD
When TO_NUMBER ((TO_CHAR (DOCUMENT_TIMESTAMP, 'YYYY') |)) To_char (DOCUMENT_TIMESTAMP, 'MM'))) between TO_NUMBER (TO_CHAR(sysdate, 'YYYY')-1). ' 01' and TO_NUMBER (TO_CHAR(sysdate, 'YYYY')-1 |) To_char (sysdate, 'MM'))-1
then "PYTD".
else "Others" end up as ABC

Hello

I find trunc to be more readable:

SQL> WITH DATA AS (
  2     SELECT SYSDATE d FROM dual UNION ALL
  3     SELECT add_months(SYSDATE, -12) FROM dual UNION ALL
  4     SELECT DATE '2009-01-01' FROM dual
  5  )
  6  SELECT to_char(d, 'dd-mon-yyyy') "Date",
  7         CASE
  8            WHEN trunc(d, 'month') = trunc(SYSDATE, 'month') THEN
  9             'Actual'
 10            WHEN trunc(d, 'year') = trunc(SYSDATE, 'year') AND d < sysdate THEN
 11             'YTD'
 12            WHEN trunc(d, 'year') = add_months(trunc(SYSDATE, 'year'), -12) THEN
 13             'PYTD'
 14         END "Case"
 15    FROM DATA
 16  ;

Date              Case
----------------- ------
10-jun-2009       Actual
10-jun-2008       PYTD
01-jan-2009       YTD

Kind regards

--
Vincent

Published by: user11163377 on June 10, 2009 02:12 - corrected the CDA column

Tags: Database

Similar Questions

  • Problem with case when try to alter the query from siimple

    Hello PL/SQL gurus and Experts.

    I'm stuck with a question (can be simple), but not gettings all headsway.
    select 365/day_num_yr Anul_Fact from Date where date_dt = trunc(sysdate -1) 
    value returns is as - 1.46

    need to write it in the form of case (I have to multiply it to some other outer query), I want to store variable ina and then use the same in an outside -.
    but when use the following syntax, then it always returns 0 and not the same output returned by the query above without the scabbard.
    select (case when date_dt =trunc(sysdate -1) then 365/day_num_yr else 0 END) Anul_Fact 
    Help kindly, I appericate your time and effort in advance.

    user555994 wrote:
    Problem is that I do not get the output as 1.46, even the output is coming like the 0 only if using the query - next

    select /*date_dt, sysdate - 1 prev_dt, trunc(sysdate - 1) trunc_prev_dt,*/
    case when date_dt = trunc(sysdate -1) then  365/day_num_yr
    else 0
    end num_day
    from date_dim;
    

    Completely, which seems to be a question of DATA. Have you checked if the table contains data for DATE_DT = SYSDATE - 1? Can you check if the data stored do not have hours and Minutes stored?

    Although I have provided examples of data, which is the same as the data in my main table and once I used the previous solution you provided and then also gives the result as same as those mentioned by you.

    I think it's something like -

    select date_dt, sysdate - 1 prev_dt, trunc(sysdate - 1) trunc_prev_dt,
    case when date_dt = trunc(sysdate -1) then  366/day_num_yr where day_num_yr=(select day_num_yr from date_dim where date_dt = trunc(sysdate -1))
    else 0
    end num_day
    from date_dim;
    

    Once we get the day_num_yr then he deviding by 366/day_num_yr :(
    but he does not like throwing an error ORA-95 - missing keyword

    Yes, it does not work

    -case when date_dt = trunc (sysdate-1) then 366/day_num_yr where day_num_yr = (select day_num_yr from the date_dim where date_dt = trunc (sysdate-1))

    due to a syntax of alien.
    I don't think that you really need. I already said, with the data in your Table, you will be having only * 1 * record with a Non - zero value. Thus, simply apply a filter to extract the corresponding record SYSDATE - 1 and you should get an output which is Non-zero. If you apply a where predicate, then would not need you a CASE statement. You can directly use something like below:

    select date_dt, sysdate - 1 prev_dt, trunc(sysdate - 1) trunc_prev_dt,
           365 / day_num_yr num_day
      from t4
     where date_dt = trunc(sysdate - 1);
    

    Published by: Jen K, September 7, 2012 16:00

  • Interview with case/when &amp; sum() over (partition) producing unexpected lines

    Since some time ago, I asked a question in this forum on an unusual problem of join and subtract ( subtract the total periods of highest level duration ). I had what seemed like a work request. So far, I could not really use it. Now that I'm looking closer results, I think that there is something wrong with it, but I can't understand why it's happening.

    Using the definition of the table of the original question, the following simple query shows a special extract of the data I'm looking at.

    Select duration, event_type, start_time, code_range, request_id from MYTABLE where REQUEST_ID = 'abc '.

    This translates into the following lines (separate columns by ' / '):

    START_TIME/REQUEST_ID/EVENT_TYPE/CODE_RANGE/DURATION
    2010-11-12 01:42:04.0/abc/Junk/publicEntryPoint/2,003
    2010-11-12 01:42:04.0/abc/Junk/webServiceCall/947
    2010-11-12 01:42:04.0/abc/Junk/webServiceCall/969

    Another similar request with REQUEST_ID = 'def' means:

    START_TIME/REQUEST_ID/EVENT_TYPE/CODE_RANGE/DURATION
    2010-11-12 00:22:13.0/def/junk/webServiceCall/788
    2010-11-12 00:22:13.0/def/junk/webServiceCall/1,128
    2010-11-12 00:22:13.0/def/junk/publicEntryPoint/2,003

    What follows is an excerpt simplified query I have a problem with:

    Select value start_time request_id event_type, code_range, duration, case code_range
    When "publicEntryPoint" then length * 2 - sum (duration) over (partition by request_id)
    of another-1
    end inner_duration from MYTABLE where EVENT_TYPE = 'spam' and trunc (START_TIME) = to_date('2010-11-12','yyyy-mm-dd')
    and rownum < 1000;

    Notice the couple of unconventional functions used here, the ' case/when' and 'sum() over (partition).

    This property returns a bunch of lines (count: 999), but here are the two with the particular REQUEST_ID values:

    START_TIME/REQUEST_ID/EVENT_TYPE/CODE_RANGE/DURATION/INNER_DURATION
    2010-11-12 01:42:04.0/abc/junk/publicEntryPoint/2,003/2,003
    2010-11-12 00:22:13.0/def/junk/publicEntryPoint/2,003/87

    The second line is correct. The first line has an unexpected value of INNER_DURATION of 2003. It should be 87 as the second row. I don't understand why this is happening.

    I think that 'and rownum '.<1000" must="" be="" the="" problem.="" it="" must="" be="" excluding="" some="" of="" the="" rows="" needed="" for="" the="" sum.="" the="" analytic="" function="" will="" be="" applied="" after="" this="" condition--see="" the="" sql="">

    Analytical functions are the last set of operations performed in a query, except for the
    final ORDER BY clause. Every joint and every WHERE, GROUP BY and HAVING clauses are
    completed before the analytical functions are processed

    Have you tried the query without this condition?

    Kind regards
    Bob

  • Subselect with clause with and nvl() with case when as 2nd argument does not work

    I get an error for this one

    Select)

    with x

    (select 1 of the double)

    Select

    NVL (x.a, cases where x.a is null then fine otherwise 3 2)

    the double)

    of the double

    Error is:

    ORA-00904: 'X '. "' A ': invalid identifier

    ... related to the use of x.a in an expression box as the 2nd argument of nvl (...)

    Rgds,

    Frank

    Hello

    Maybe like this?

    Select)

    with x

    (select 1 of the double)

    Select

    NVL (x.a, case when x.a is null, then Itf_Pkg.Itf_Null_Value ("x.a', 'a null value'") or 3 end)

    X)

    of the double

  • Need help with CASE When statement in a Where Clause

    So I have a SQL (simplified for this forum)

    Select t1.*
    from table1, table2 t2 t1
    where t1.field1 = t2.field1
    and when t1.field2 is null then trunc (sysdate) < = trunc (t1.date1 + 17)
    of another trunc (sydate) > = end of trunc (t2.date2 + t2.date3)

    I end up getting an error ORA-00905: lack of keyword

    I'm sure that I just got something here involved.

    You can not make the comparison within the statement underlying case like this. Assuming you have appropriate data types, something like this should work

    Select t1.*
    from table1 t1, table2 t2
    where t1.field1 = t2.field1
      and ((t1.field2 is null and
            trunc(sysdate) <= trunc(t1.date1 + 17)) or
           trunc(sydate) > = trunc(t2.date2 + t2.date3))
    

    John

  • Problem with Case statement

    I try to use a case statement in a report of the Apex, but I get an error message.

    It comes to my sql

    CASE WHEN EXISTS (select stg.extkey, distsubtrpgrpid

    of udm_da da

    udm_di di

    udm_distsubtrpgrp stg

    where di.disttransgrpid = stg.disttransgrpid

    and da.daid = di.daid

    and da.suid = su.suid)

    THEN

    Select stg.extkey

    of udm_da da.

    udm_di di,

    udm_distsubtrpgrp stg

    where di.disttransgrpid = stg.disttransgrpid

    and da.daid = di.daid

    and da.suid = ' | Qul SUID. '

    Stg.extkey group, distsubtrpgrpid

    Union

    Select stg.extkey

    of stg udm_distsubtrpgrp

    where distsubtrpgrpid! = - 1

    and distsubtrpgrpid = ' | NVL (su.distsubtrpgrpid-1). '

    order by 1

    WHEN su.distsubtrpgrpid IS NOT NULL

    THEN

    Select stg.extkey, distsubtrpgrpid

    of stg udm_distsubtrpgrp

    where distsubtrpgrpid! = - 1

    and distsubtrpgrpid = ' | NVL (su.distsubtrpgrpid-1). '

    order by 1

    ON THE OTHER

    NULL VALUE

    END DISTSUBTRPGRP_1

    Any help appreciated

    Gus

    GusC wrote:

    Yes you are right.

    My sql must be

    CASE WHEN su.distsubtrpgrpid IS NOT NULL

    THEN

    Select stg.extkey, distsubtrpgrpid

    of stg udm_distsubtrpgrp

    where distsubtrpgrpid! = - 1

    and distsubtrpgrpid = su.distsubtrpgrpid

    ON THE OTHER

    NULL VALUE

    END DISTSUBTRPGRP_1

    But the report won't save

    Gus

    No, your SQL is not that.

    The select statement that you put online here, aside from being not not in brackets, is the selection of two values, but you can provide two values for the result column.

    Without knowing who the SQL statement, we can highlight only the obvious questions.

  • "CASE WHEN 1 = 0 THEN... ON THE OTHER... END '?

    This might be a very basic question I'm still confused about it.
    Can you explain me please "BOX WHEN 1 = 0 THEN... ON THE OTHER... END '?
    Where and why to use this declaration?


    Help appreciated.

    First Let's break down what it means. Because 1 is never equal to 0, OBI will ignore what comes immediately after and run what comes after the ELSE.

    So, why would we do that? Well, often we want to perform an action that has nothing to do with a particular column in our field. Using this CASE statement, trick us OBI into thinking that we use a column for a calculation or action, but in fact, the column is unchanged.

    For example, suppose that you have been the construction of a line of dashboard. You want to use a column twice in the dashboard command prompt, for example a column ACCOUNT_OPEN_DATE for a range of dates. You cannot use the same column twice in a row of dashboard. (Try it, OBI will ignore your attempt to put the same column twice in your workspace).

    So, what are you doing? You first get a column (in this example, I use a column of type CHAR) as the name of the branch. It doesn't matter which column you are using. The TANK is used the syntax is so logical.

    Move the column to your workspace. Now you click on the amending formula and you type CASE WHEN 1 = 0 THEN organization. "" The branch name ' ELSE 'TEST' END.
    So in this case, the values of the branch name are not affected and the dummy column represents just the word 'TEST '. Now in the 'Show' of the command prompt part, we switch to 'SQL results' and SELECT 'attributes of the account' type. Account_Open_Date OF THE industry and together for a PV called StartDate.

    Because the column is a model, you can call it in fact once again. Use the instruction BOX even make a "dummy" column Then use the same SQL, you used previously, but this time save it in a TICKET called EndDate.

    You now have two date values, you can use your ACCOUNT_OPEN_DATE column to get a date range.

    So, in conclusion, normally you choose a column in the subject box, because you have the values in this column in your report. But when you just need a column to do something unrelated to any column, you use CASE 1 = 0 to make a "dummy" column, and then you can perform your action.

    HTH,

  • Box When sql with clob in the criteria

    I have the following select statement with a 'case when' which has a clob field in the criteria.
    I get an ORA-00932 inconsistent types of data: expected - got CLOB error.
    CASE WHEN FROM_FIELD = 'REOPEN'
    THEN
    (SELECT MIN(MODIFIED_DATE)
    FROM RECORDS
    WHERE MODIFIED_VALUE = 'CLOSE')
    ELSE CLOSED_DATE
    END
    [/CODE]
    
    There is a lot more to the SQL above, but it is basically what I am looking for.
    Looking for help with how to run this with the CLOB field (Modified_Value) in the criteria.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

    A strange with clob column is

    SELECT MIN(MODIFIED_DATE)
    FROM RECORDS
    WHERE MODIFIED_VALUE = 'CLOSE';
    will give you error 
    
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got CLOB
    

    But

    SELECT MIN(MODIFIED_DATE)
    FROM RECORDS
    WHERE MODIFIED_VALUE like '%CLOSE%';
    

    This will give record... :)

  • OR with case in SQL?

    I have asked to do a report, I

    case ph.action_taken
    When "V".
    then... {the expression complex}

    What I want is to say if ph.action_taken is T, V or Z - F
    then make the expression complex without having to put in the complex expression
    4 times. How to use an RC with case in SQL?

    Thank you

    Use a different approach to the CASE and the IN operator. Like this:

    with t as (select 'A' a from dual)
    select case
             when t.a in ('A','B','C') then 'OK'
             else 'Not OK'
           end b
    from t           
    
  • in iBooks author, how can I change the book ID?  I update often books and hand but ID remains the same, so it caused problems when others discover.  I wish it were as if it were a new book with a new code.

    in iBooks author, how can I change the book ID?  I update often books and hand but ID remains the same, so it caused problems when others discover.  I wish it were as if it were a new book with a new code.

    From the link 'related items' below, see:

    Give your book a new internal ID.

  • any case when and the sql clause

    Hello:
    What follows is my sql clause:
    SELECT T.*, b.name
    OF dbtest1 t
    LEFT OUTER JOIN dbtest b ON t.NO = b.empno
    WHERE t.ChineseName like '% "| : ChineseName | ' %' AND b.name like "%" | : name | » %'
    ORDER BY t.ChineseName

    The main problem is that I want to check the b.name if it is null, it can be passed as function NVL, so I try using case when, but it does not work.
    When there are the b.name in where clause, the columns of result will not include data without b.name (or implies the b.name is NULL); And that
    the result data are not entirely accurate.
    is it possible to use the case when it is implemented in the following code snippet:

    -case when b.name is not NULL then b.name like "%" | : name | » %'
    Else b.name = NULL (b.name = b.name does not seem to work on the analysis of data zero)
    end

    Thank you very much.

    962769 wrote:
    The main problem is the table is the form of the cross, and the like clause will filter the
    data without a name. Basically, it should show the empty columns, however, it won't.
    so, when I test the sql code, I fhound Like "%" | b.Name | ' %' will not get the data when the original dbtest1 table data
    has no id corresponding to the BD test. It seems pointless to go the LEFT OUTER JOIN.

    Thank you

    WHERE t.ChineseName like '%'||:ChineseName||'%'
    AND  (
            b.name like '%'||:name||'%'
           or b.empno is null
        )
    
  • HI, I'M PREPARING THE MARKSHEET PROGRAM IN PL/SQL WITH THE CASE BUT I FOUND SOME MISTAKE CAN SOLVE THIS ERRORS...

    DECLARE

    V_TOT_MARKS NUMBER CONSTANT: = 500;

    V_MKS_OBT NUMBER: = 0;

    NUMBER of V_FPAPER: = NVL (& FIRST_PAPER, 0);

    NUMBER of V_SPAPER: = NVL (& SECOND_PAPER, 0);

    NUMBER of V_TPAPER: = NVL (& THIRD_PAPER, 0);

    V_4PAPER NUMBER: = NVL (& FOURTH_PAPER, 0);

    V_5PAPER NUMBER: = NVL (& FIFTH_PAPER, 0);

    NUMBER OF V_PER (5.2): = 0;

    V_GRADE VARCHAR2 (05);

    V_RES VARCHAR2 (30);

    BEGIN

    V_RES: = V_FPAPER > = 40 AND V_SPAPER > = 40 AND V_TPAPER > = 40 AND V_4PAPER > = 40 AND V_5PAPER > = 40;

    V_MKS_OBT: = V_FPAPER + V_SPAPER + V_TPAPER + V_4PAPER + V_5PAPER;

    V_PER: = TRUNC ((V_MKS_OBT / V_TOT_MARKS) * 100, 2);

    V_RES: = CASE WHEN V_PER BETWEEN 95 AND 100 THEN V_GRADE 'A-1 '.

    WHEN V_PER BETWEEN 85.00 AND 94.99 THEN V_GRADE "A".

    WHEN V_PER BETWEEN 75.00 AND 84.99 CAN V_GRADE 'B '.

    WHEN V_PER BETWEEN 40.00 AND 74.99 V_GRADE THEN 'C '.

    WHEN V_PER BETWEEN 30,00 AND 39.99 V_GRADE CAN "FAIL".

    END OF ANOTHER "FAILED."

    DBMS_OUTPUT. PUT_LINE (' FIRST BRANDS OF PAPER: = ' |) V_FPAPER | (' / 100');

    DBMS_OUTPUT. PUT_LINE ("SECOND BRANDS PAPER: = ' |") V_SPAPER | (' / 100');

    DBMS_OUTPUT. PUT_LINE (' THIRD PAPER BRANDS: = ' |) V_TPAPER | (' / 100');

    DBMS_OUTPUT. PUT_LINE (' FOURTH BOOK BRANDS: = ' |) V_4PAPER | (' / 100');

    DBMS_OUTPUT. PUT_LINE ("BOOK MARKS FIFTH: = ' |") V_5PAPER | (' / 100');

    DBMS_OUTPUT. PUT_LINE ('TOTAL POINTS: = ' |) V_MKS_OBT | » /'|| V_TOT_MARKS);

    DBMS_OUTPUT. PUT_LINE (' % / GRADE: = ' |) V_PER: ' / ' | V_GRADE);

    END;

    /

    A lot of mistakes in your block, I think that you are looking for something like this:

    DECLARE
      V_TOT_MARKS CONSTANT NUMBER := 500;
      V_MKS_OBT   NUMBER          := 0;
      V_FPAPER    NUMBER          := NVL ( &FIRST_PAPER, 0 ) ;
      V_SPAPER    NUMBER          := NVL ( &SECOND_PAPER, 0 ) ;
      V_TPAPER    NUMBER          := NVL ( &THIRD_PAPER, 0 ) ;
      V_4PAPER    NUMBER          := NVL ( &FOURTH_PAPER, 0 ) ;
      V_5PAPER    NUMBER          := NVL ( &FIFTH_PAPER, 0 ) ;
      V_PER       NUMBER ( 5, 2 ) := 0;
      V_GRADE     VARCHAR2 ( 05 ) ;
      V_RES       VARCHAR2 ( 30 ) ;
    BEGIN
      V_MKS_OBT       := V_FPAPER + V_SPAPER + V_TPAPER + V_4PAPER + V_5PAPER;
      V_PER           := TRUNC ( ( V_MKS_OBT / V_TOT_MARKS ) * 100, 2 ) ;
      select case
      WHEN V_PER BETWEEN 95 AND 100 THEN 'A-1'
      WHEN V_PER BETWEEN 85.00 AND 94.99 THEN 'A'
      WHEN V_PER BETWEEN 75.00 AND 84.99 THEN 'B'
      WHEN V_PER BETWEEN 40.00 AND 74.99 THEN 'C'
      WHEN V_PER BETWEEN 30.00 AND 39.99 THEN 'FAIL'
      ELSE 'FAIL'
      end
      INTO V_GRADE
      from dual;
      DBMS_OUTPUT.PUT_LINE ( 'FIRST  PAPER MARKS := '||V_FPAPER||'/100' ) ;
      DBMS_OUTPUT.PUT_LINE ( 'SECOND PAPER MARKS := '||V_SPAPER||'/100' ) ;
      DBMS_OUTPUT.PUT_LINE ( 'THIRD  PAPER MARKS := '||V_TPAPER||'/100' ) ;
      DBMS_OUTPUT.PUT_LINE ( 'FOURTH PAPER MARKS := '||V_4PAPER||'/100' ) ;
      DBMS_OUTPUT.PUT_LINE ( 'FIFTH  PAPER MARKS := '||V_5PAPER||'/100' ) ;
      DBMS_OUTPUT.PUT_LINE ( 'TOTAL  MARKS       := '||V_MKS_OBT||'/'||V_TOT_MARKS
      ) ;
      DBMS_OUTPUT.PUT_LINE ( 'PER% / GRADE       := '||V_PER||' / '||V_GRADE ) ;
    END;
    /
    
  • Select the case when several returnvalue? 20 D

    Hello
    I would like to know if there is a solution less than 10g for something like this

    Select case when 'C' = 1
    then
    (select double 1,2,3,4,5)
    on the other
    (select double 6,7,8,9,0)
    end
    of the double.
    (select 1 double 'C')

    What I really need, is the full output of (select double 1,2,3,4,5) or (select double 6,7,8,9,0) If a State due to a different sql query is true or false. No matter if the solution uses 'case when' or anything else.

    Thanks in advance for any help.
    Best regards
    Carsten

    Something like this would work with the example you gave.

    SQL> with test_data as
      2      (select 1 c from dual)
      3  select
      4      1, 2, 3, 4, 5
      5  from
      6      dual,
      7      test_data
      8  where
      9      c = 1
     10  union all
     11  select
     12      6, 7, 8, 9, 0
     13  from
     14      dual,
     15      test_data
     16  where
     17      c != 1;
    
             1          2          3          4          5
    ---------- ---------- ---------- ---------- ----------
             1          2          3          4          5
    
    SQL> edi
    Wrote file afiedt.buf
    
      1  with test_data as
      2      (select 2 c from dual)
      3  select
      4      1, 2, 3, 4, 5
      5  from
      6      dual,
      7      test_data
      8  where
      9      c = 1
     10  union all
     11  select
     12      6, 7, 8, 9, 0
     13  from
     14      dual,
     15      test_data
     16  where
     17*     c != 1
    SQL> /
    
             1          2          3          4          5
    ---------- ---------- ---------- ---------- ----------
             6          7          8          9          0
    
  • Problem to create CASE WHEN OBIEE

    Hello world

    I need to create a field to calculate in the responses of the Oracle with the sentence in the CASE.

    But I can't because I try to do this:

    BOX WHEN "Las Coronaria. "" Your note Csdst "> 8 CAN ' > 8' OTHER 'Las Coronaria. "" Your note Csdst ' END

    and OBIEE send me the following error:

    [nQSError: 10058] A general error occurred. [nQSError: 22027] Union of incompatible types. (HY000)
    Issued SQL statement: SELECT "Las Coronaria. "' Your Csdst note ', CASE WHEN"Las Coronaria. "" Your note Csdst "> 8 CAN ' > 8' OTHER 'Las Coronaria. "" Csdst your note ' the end 'INDICATORS CLINICOS.


    Why?

    Kind regards
    Daniel Hidalgo

    Since WHEN a part are tank and part ELSE is the number type.
    Make the similar data as type

    BOX WHEN "Las Coronaria. "' ACE Csdst ' > 8 THEN ' ELSE cast > 8' ("Puntajes Coronaria". "END ACE Csdst' as char)

    Pls mark as correct

  • Update query with case

    my table: workingdate

    SNO name startdate
    1 ss 12/01/2011
    2 bb 11/01/2011


    I can update name or date start or two .i will pass a new date, name of update through front end.

    I need to validate the condition in the event, that is when the new date after check if it is higher, then start date. If it is higher, then it should be updated with the new start date.
    If not, it must be updated, it will be the old value.

    I use it under request

    Update workingdate set name = 'sss', startdate =)
    case
    When
    (TO_DATE('2011-12-10','yyyy-MM-dd') > (select TO_DATE(startdate,'yyyy-MM-dd') from the workingdate, when sno = 1))
    then TO_DATE('2011-12-10','yyyy-MM-dd')
    on the other
    Select TO_DATE(start_date,'yyyy-MM-dd') in the workingdate, when sno = 1
    end
    )
    where sno = 1;


    but when I run the above query, it shows me


    Error report:
    SQL error: ORA-00936: lack of expression
    00936 00000 - "missing expression.
    * Cause:
    * Action:

    How could I solve this problem...

    Check this

    UPDATE workingdate
    SET NAME='sss',
         startdate=(CASE WHEN (TO_DATE('2011-12-10','yyyy-MM-dd') > startdate THEN TO_DATE('2011-12-10','yyyy-MM-dd') ELSE start_date END)
    WHERE sno=1;
    

    See you soon
    Kanchana

Maybe you are looking for

  • HP elitebook 8440p: Ricoh Bay8 controller

    Can someone tell me what multifunctional Ricoh Bay8 and it's a driver on my hp elitebook 8440p?

  • COMPAC PRESARIO CQ61: Driver for OPTICAL DRIVE CD/DVD Presario cq61 laptop

    I could not download the driver for my CD/DVD optical drive on the HP site, message again me 'portlet is unavailable"- can someone send me a link to download the driver for my CD/DVD device.   When I go to 'my computer', the drive of the device does

  • show a vi that is normally hidden

    Hi guys,. I have a VI that has a Subvi constantly running in the back ground, but I want a button on the main VI to allow a user make the Subvi visible, then when the user closes the void VI I want to go back to running in the background. So I want t

  • SPA-2100 continues to Flash.

    Hi all After receiving the SPA-2100, I have a problem with it. SPA-2100 more return as ATA. He seems to be in this stadium and never comes out: Slow flashing (0.5 sec ON, continues to 0.5 s OFF) Initialization of the system; only occurs at the start

  • Update of Smartphones from blackBerry Curve 9360 - lost all ringtones

    Hi all yesterday I updated my BB Curve 9360 to software version 7.1 Paket 2814. Unfortunately I lost all my standard ringtones and I have found no solution to get back them. The only way is to buy new. Does any body know a fix for this? Thanks in adv