Help with CASE Expression

Hi Experts !
can you please help me out is removing bug from this statement
select
CASE when p.ASSIGNED is null then
+(+
SUM (
CASE WHEN P.STATUS = 'waiting'  AND P.TYPE_ID=1 and trunc(P.INSERT_DATE)= trunc(Sysdate)
and p.INITIATED_BY = 51 and p.IS_DELETE='No'   THEN 1 ELSE 0 END
+) planToday,+
SUM (
CASE WHEN P.STATUS = 'waiting' AND P.TYPE_ID=1
and p.INITIATED_BY = 51 and p.IS_DELETE='No'  THEN 1 ELSE 0 END
+) planTotal+
+)+
ELSE
+(+
SUM (
CASE WHEN P.STATUS = 'waiting'  AND P.TYPE_ID= 1 and trunc(P.INSERT_DATE)= trunc(Sysdate)
and p.ASSIGNED = 51 and p.IS_DELETE='No'  THEN 1 ELSE 0 END
+) planToday,+
SUM  (
CASE WHEN P.STATUS = 'waiting' AND P.TYPE_ID=1
and p.ASSIGNED = 51 and p.IS_DELETE='No'  THEN 1 ELSE 0 END
+) planTotal+
+)+
END
from WF_PLAN P
when i run the query, it gives me
Error Ora - 00907 : 'Missing Right Parenthesis'
Please help out!
Edited by: Zia on Jun 1, 2010 12:55 AM

What exactly are your expecting the below given segment to display? Two different columns? (That's not the way to get it done)
        CASE when p.ASSIGNED is null then
            SUM (
                CASE WHEN P.STATUS = 'waiting' AND P.TYPE_ID=1 and trunc(P.INSERT_DATE)= trunc(Sysdate)
                and p.INITIATED_BY = 51 and p.IS_DELETE='No' THEN 1 ELSE 0 END
            SUM (
                CASE WHEN P.STATUS = 'waiting' AND P.TYPE_ID=1
                and p.INITIATED_BY = 51 and p.IS_DELETE='No' THEN 1 ELSE 0 END
        )also you cannot alias a column within case..end.
*009*
Edited by: 009 on Jun 1, 2010 12:17 AM

Similar Messages

  • Need help with Airport Express and so on.

    Ok so my main problem before getting into what I need help with here is that our MacBooks and now my iPhone 6 plus isn't staying online. Keep getting booted off and then I either have to select the network again or it will eventually go back on. If anyone has a solution or so please feel free to answer that as well. I'm running on Roadrunner with a Netgear 600 wireless router and a motorola modem. Both of which I'll leave the link to below for a better look.
    My Main Question: So I'm looking at a new wireless router mainly and possibly a new modem. I know Apple products are trustworthy but how good is the Airport Express and other Airport products. Also what is the Maximum speed and Maximum data speed for the cheapest express station and if anyone knows the speeds of the other devices it would be greatly appreciated.

    DSL Router to Netgear 5-port Switch and I used the switch to connect to Airport Extreme, TV, Blue-Ray DVD player and DirecTV Receiver.
    The AirPort Extreme base station (AEBS) is a router so it will do what you need.
    You need to reconfigure your setup. Connect the WAN port of the AEBS to the DSL router. Then connect the Netgear switch to one of the LAN ports on the AEBS. The AEBS will properly share the connection.

  • Help with time expression!

    Hi everyone, I need some help with the time expression.
    Im working with video copilot´s plugin element 3d and i've made a spere shaped thing with particles which im going to sync to music. The problem is that when i make the simple expression "time*321" on the noise evolution value to make the sphere move organicly throughout the whole video it only does so for about two minutes then it just stops changing even though the value changes. The pictures might help you understand.
    Pictures: http://puu.sh/adNNB/e8de72a1e8.jpg, http://puu.sh/adNQJ/4fe8d4fe94.jpg, http://puu.sh/adNRx/8ecff2b2ca.jpg
    Then there is another problem which is that the sphere evolves alot faster with the time set to 321 compared to when i have it on 30.
    I hope you can help me and im sorry for my bad english just tell me if there is something you dont understand.

    I think you are giving the rotation value more than it can handle. After a while, many of the values in AE will stop increasing because the math can't go any further. Here are two things for you to try.
    1) Use this simple expression for increasing the value of something.
    THE BIG PICTURE:  ([Amount of Change] / [Number of Seconds]) * time
    ROTATION EXAMPLE: (360 / 5) * time;   <----- This will rotate a layer 360º over 5 seconds. It will also continue to rotate until the end of the comp or you run out of math.
    POSITION EXAMPLE:  delta = (500 / 2) * time; // This changes the value of "delta" 500 units over 2 seconds and continues.
                                       x = value[0] + delta; // Uses the x value from frame 0 and adds the delta to provide movement
                                       y = value[1]; // Uses the y value
                                       [x, y] // sends the values back to the layer
    2) Modulus will recycle the numbers. Using your current expression, you can add modulus, and use it to recycle your math.
    EXPRESSION:  (time * 321) % 360
    The % is the modulus, and it resets the count every 360º.
    Good luck!
    Trent

  • Cube or Group By columns with Case Expressions with a total row (SQL Server 2008)

    I am trying to create a summary tabe of some data. I think that I can use Cube(my heart is not set on it though), but I cant figure a way to define new columns via a case expression and sum the new column.  Lastly, I need to create a total row at the
    bottom and I have no idea of how to do that except percent run the query and then run it again without the travel_city and union all the two tables
    group by travaled_city, [COL1] =sum(expense) when dept = 1, [COL2]=sum(expense) when dept = 2, [COL3] = sum(expense) when group = 3, =[COL4]=sum(expense) when group = 1 and  expense code = 0100,[COL5]= sum(expense) when group = 2 and  expense code
    = 0100, [COL6]sum(expense) when group = 3 and  expense code = 0100, [COL7]=sum(expense) when (exp_paid)<30, [COL8] = sum(expense) when dept in ('4','5','6')
    and have a grand total of each column
    any help is greatly appreciated

    Would this work?
    select travaled_city,
    sum(case dept when 1 then expense else 0 end) as [COL1],
    sum(case dept when 2 then expense else 0 end) as [COL2], ...

  • Help with CASE MANAGEMENT

    Hi Experts,
    I am working with Case Management, and I have to create Cases with all its specifications automatically. Anybody knows how I can create it? or Anybody have any suggestion or documentation to start with this.
    Thanks in advance.
    Regards,
    Beatriz.

    Hi,
    Easy transaction to Case Management customizing is SCASE_CUSTOMIZING. There you have an overview of the customizing of case management.
    Also carryon these steps one by one...
    Case Management Basic Settings :
    Define Number Range Intervals for Case
    Define Case Types
    Determine Permitted values for attribute
    Create values for "Category" attribute
    Create values for "Cause" attributes
    Create values for "Priority" attribute
    Create values for "Reason" for escalation attribute
    Assign escalation reasons to an attribute profile
    Create values for "Authorization level" attribute
    System Modifications
    Create status profile
    Create Text profile
    Create Text Ids
    Create Text Profile
    Define Logical system for external objects
    Enhanced System modifications
    Note About Enhanced System Modifications
    Define Processes
    Set up registry
    Create/Change Case Record Model
    Create Profiles
    Create attribute profile
    Create function profile
    Create terminology profile
    Create Activities for authorization check
    Activate application log
    Define processes
    Create/Change Case Record Model
    When u open the Transaction SCASE_CUSTOMIZING , there will be Registry Steps...
    Follow them step by step.
    For any queries reply.
    Regards,
    Eswari.

  • Help with this expression.

    Hey everyone,
    I'm not the best at expressions, but i'm trying to learn and was wondering if someone could tell me what is wrong with the expression I have. It is from a tutorial found in video copilots pro scores, and its purpose is to be able to randomly distribute many layers over x, y, and z space.. without having to manually place them.
    I tried this expression last night, and it gave me a similar error. Tried it again today and it seemed to work, but then I decided to precomp my layer and it broke the expression, so I went to type it again.
    Below is what I typed, and the subsequent error message. It tells me the error is on line 3, and the rest you can see.
    If someone could point out where I went wrong here I would greatly appreciate it.
    Thanks,
    Dan

    I actually undo'd until the original expression that "worked" came back, copied it, and pasted in the position field of the precomp, and I get the same error.
    Kinda confused, especially since the expression was exactly the same.

  • Help with assignment expression

    Hi All,
    I'd like to ask you for help regarding one assignment in MDM.
    We have text field: "Material_Long_Description" (as a concatenation of 8 attributes) - the field length is unlimited, e.g.:
    "attribute1,attribute2,attribute3,attribute4,attribute5,attribute6,attribute7,attribute8".
    We need to have "Material_Short_Description" - limited to 40 symbols so I have created assignment:
    LEFT(Material Long Description,40) and the result is: "attribute1,attribute2,attribute3,attribu",
    but we also need not to have cut one of the attributes on the middle and half attribute and teh comma(",attribu") to be removed - the aim is in this case to have: "attribute1,attribute2,attribute3".
    I've tryed with function FIND but didn't find solution.
    This was implemented in SQL Database with the following query:
    set Material_Short_Description = left(Material_Long_Description,(40 - locate(",", reverse(left(Material_Long_Description,40)))))
    and it works perfectly well, but such a function "reverse" does not exists in MDM.
    Any suggestions how we can implement this logic in MDM without API programing?
    Thanks in advance,
    ILIN

    Hi llin,
    You are retrieving these attributes values which you have given in Attribute text values for attribute name in taxonomy mode. Why don't you change these values there itself in taxonomy mode for Attribute values.
    like you have Attribute A who has text values as 3 - 4 and 5 - 6, change it to 3-4 and 5-6 rather than using any logic in assignment expression.
    If you still want to use assignment expression for the same then it would be really lengthy but it is working fine at my end.
    I denote Attribute1 = A1, Attribute2 = A2 and so-on till Attribute8 = A8
    This expression you will run on Material_Long_Description, i mean on text large field.
    I understand you don't want to maintain space for Short description, but i would suggest as you populate concatenation of attribute values data on Material_Long_Description, why don't at this point of time you take care of space and populate your Material_Long_Description free from space character. Further when you populate this data in Short Description, you just need to use logic as given by me above and don't need to bother about space character for Attribute values as they are already corrected while populating Material_Long_Description.
    Assumption:
    I am assuming whenever "-" hyphen character comes it is always append and prep-end with space character " ".
    I mean, you have always values as "3 - 4" or "3-4" in attribute not as "3 -4" or "3- 4"
    Procedure:
    Create an Assignment: give the Assignment field as Material_Long_Description.
    Now right click on this assignment-->Add Branch.
    Select the Branch Value of that category: Write Assignment Expression here in this Add Branch Assignment as given below:
    IF(MID(A1,FIND(A1,"-")-1,1)=" " AND
    MID(A1,FIND(A1,"-")+1,1)=" ",
    LEFT(A1,FIND(A1,"-")-2)
    &MID(A1,FIND(A1,"-"),1)
    &MID(A1,FIND(A1,"-")+2),
    A1)&","&
    IF(MID(A2,FIND(A2,"-")-1,1)=" " AND
    MID(A2,FIND(A2,"-")+1,1)=" ",
    LEFT(A2,FIND(A2,"-")-2)
    &MID(A2,FIND(A2,"-"),1)
    &MID(A2,FIND(A2,"-")+2),
    A2) and so-0n till 8th Attribute(A8)
    Logic: 1stly it will look Attribute value which has space character " " before and after Hyphen "-", eg "3 - 4", then it will populate value as 3-4, else if it doesn't find space character " " before and after "-" Hyphen it will just put there same attribute value. e.g if it is already 3-4, it will just place it same as 3-4.
    Just check this above expression and revert with the result, It is working fine at my end.
    Thanks and Regards,
    Mandeep Saini

  • Need help with regular expression

    I'm trying to use the java.util.regex package to extract URLs from html files.
    The URLs that I am interested in extracting from the HTML look like the following:
    <font color="#008000">http://forum.java.sun.com -
    So, the URL is always preceeded by:
    <font color="#008000">
    and then followed by a space character and then a hyphen character. I want to be able to put all these URLs in a Vector object. This doesn't seem like it should be too difficult but for some reason I can't get anywhere with it. Any help would be greatly appreciated. Thanks!

    hi gupta am not sure of the java syntax but i can tell u about the regular expression...try this....
    <font color="#008000">(http:\/\/[a-zA-Z0-9.]+) [-]
    i dont know the java methods to call...just the reg exp...
    Sanjay Acharya

  • Please help with regular expression

    Hello,
    With the help of my previous posting answers, Re: Procedure to Extract multiple substring from a string , I updated the query. But, I am not getting desired answer in all case. Could you please help me out? My query is based on the previous posting. Any other simple way to achieve this?
    I will really appreciate it.
    select
           ltrim ( regexp_substr(txt, '\[(\w+)', 1, level), '[')      as id, /* id is number */
           ltrim ( regexp_substr(ltrim ( regexp_substr(txt, ':[^]]+', 1, level), ':'), '\w+-*\d*', 1, 1), ':')  as qid, /* Qid could be char/number/space any combination except ':' */
           ltrim ( regexp_substr(ltrim ( regexp_substr(txt, ':[^]]+', 1, level), ':'), '\w+', 1, 2), ':')      as num,
          to_date( ltrim ( regexp_substr(ltrim ( regexp_substr(txt, ':[^]]+', 1, level), ':'), '[^:]+', 1, 3), ':'),'MM/DD/YY')   as effdate
    from  (
                            select  '[10946:M100:N:][10947:Q1222:N:][38198:PPP-2:N:][13935:PPP-6:N:][38244:QQQ-4:Y:01/01/10]'     as txt
                            from     dual
            connect by level <= length(regexp_replace(txt, '[^[]'));I should get :
    ID             QID          NUM         EFFDATE
    10946     M100     N     
    10947     Q1222     N     
    38198     PPP-2     N     
    13935     PPP-6     N     
    38244     QQQ-4     Y     01-JAN-10But, getting
    ID             QID          NUM          EFFDATE
    10946     M100     N     
    10947     Q1222     N     
    38198     PPP-2     2     
    13935     PPP-6     6     
    38244     QQQ-4     4     01-JAN-10Thanks,

    Hi,
    So the num column is wrong, is that it?
    Describe what the num column should be. For example "num is the 3rd part of the :-delimited list enclosed in the square brackets".
    If that's what you want, then change the definition of num from
    ...                     ltrim ( regexp_substr(ltrim ( regexp_substr(txt, ':[^]]+', 1, level), ':'), '\w+', 1, 2), ':')      as num,to
    ...                      REGEXP_SUBSTR  ( REGEXP_SUBSTR ( txt
                                          , '[^]]+'
                                                , 1
                                       , LEVEL
                             , '[^:]+'
                             , 1
                             , 3
                             )       AS num,

  • Help with Regular Expression for field validation

    I'm fairly new to using regular expressions and using Acrobat. This is probably a simple question, but I've been unable to figure it out.
    I have a text field on a PDF that I would like to be 9 characters in length. The first 2 characters can only be alphanumeric, the last 7 characters can only be numeric.
    At first I was using the following, which allows all the characters to be alphanumeric:
    var re = /^[A-Za-z0-9 :\\_]$/;
    if (event.change.length >0) {
    if (event.willCommit == false) {
        if (!re.test(event.change)) {
            event.rc = false
    That works fine, but it's not quite what I needed. With some assistance I changed it (see below) to fit what I was looking for. However, this didn't work; it prevents anything from being entered in the field:
    var re = /^[A-Za-z0-9]{2}\d{7}$/;
    if (event.change.length >0) {
    if (event.willCommit == false) {
        if (!re.test(event.change)) {
            event.rc = false
    Any help would be greatly appreciated.
    Thanks...

    Here's a function you can call form the field's custom Format script. It should be placed in a document-level JavaScript:
    function custom_ks1() {
        // Define non-commited regular expression
        var re = /^[A-Za-z0-9]{0,2}([0-9]{0,7})?$/;
        // Get all of the characters the user has entered
        var value = AFMergeChange(event);
        // Allow field to be cleared
        if(!value) return;
        if (event.willCommit) {
            // Define commited regular expression
            var re = /^[A-Za-z0-9]{2}[0-9]{7}$/;
            if (!re.test(value)) {  // If final value doesn't match, alert user
                app.alert("Your error message goes here.");
                // event.rc = false
        } else {  // not commited
            // Only allow characters that match the regular expression
            event.rc = re.test(value);
    Call it like this:
    // Custom Keystroke script
    custom1_ks();

  • Help with regular expression needed

    Hi,
    Perhaps someone here can help me with my regular expression I'm trying to build in my Java code.
    The regular expression that I'm looking to build consists of any non-whitespace character up until it finds one or two <>= symbols and then any character thereafter. So both these Strings would match the expression:
    City 1==London
    Age>=18
    The regular expression that I'm using is as follows:
    (\\S+)([><=]){1,2}(.+)However, group 1 always retrieves the first <>= symbol as in "City 1=". How can I make the <>= part greedy so that it retrieves both operator symbols?
    Thanks.

    Make the first group, the non-spaces, reluctant:
    "(\\S+?)([<>=]{1,2})(.+)"

  • Help with regular expression to find a pattern in clob

    can someone help me writing a regular expression to query a clob that containts xml type data?
    query to find multiple occurrences of a variable string (i.e <EMPID-XX> - XX can be any number). If <EMPID-01> appears twice in the clob i want the result as EMPID-01,2 and if EMPID-02 appears 4 times i want the result as EMPID-02,4.

    with
    ofx_clob as
    (select q'~
    <EMPID>1
    < UNQID>123456
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>2
    < UNQID>123457
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>1
    < UNQID>123458
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    ~' ofx from dual
    select '<EMPID>' || to_char(ids) || '(' || to_char(count(*)) || ')' multi_empid
      from (select replace(regexp_substr(ofx,'<EMPID>\d*',1,level),'<EMPID>') ids
              from ofx_clob
            connect by level <= regexp_count(ofx,'<EMPID>')
    group by ids having count(*) > 1
    MULTI_EMPID
    <EMPID>1(2)
    with
    ofx_clob as
    (select q'~
    <EMPID>1
    < UNQID>123456
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>2
    < UNQID>123457
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>1
    < UNQID>123456
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>2
    < UNQID>123456
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>1
    < UNQID>123458
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    ~' ofx from dual
    select '<EMPID>' || listagg(to_char(ids) || '(' || to_char(count(*)) || ')',',') within group (order by ids) multi_empid
      from (select replace(regexp_substr(ofx,'<EMPID>\d*',1,level),'<EMPID>') ids
              from ofx_clob
            connect by level <= regexp_count(ofx,'<EMPID>')
    group by ids having count(*) > 1
    MULTI_EMPID
    <EMPID>1(3),2(2)
    Regards
    Etbin
    Message was edited by: Etbin
    used listagg to report more than one multiple <EMPID>

  • Help With Regular Expression In Apex Validation

    Apex 3.2
    There is a validation type of regular expression in apex, but I have never used regular expression before,
    so a little help is appreciated.
    I need to validate a field. It is only allowed to contain alpha characers, numbers, spaces and the - (dash) character.
    I have tried several times to get this working
    eg
    [[:alpha:]]*[[:digit:]]*[[:space:]]*[-]*
    ^[[:alpha:][:digit:][:space:]-]+?
    and others, but just can't to get the syntax correct.
    Can someone help me with this please
    Gus

    Example:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'This is some example text' as txt from dual union all
      2             select 'And this is the 2nd one with numbers' from dual union all
      3             select 'And this allows double-barrelled words with hyphens' from dual union all
      4             select 'But this one shouldn''t be allowed!' from dual
      5            )
      6  --
      7  select *
      8  from t
      9* where regexp_like(txt, '^[[:alnum:] -]*$')
    SQL> /
    TXT
    This is some example text
    And this is the 2nd one with numbers
    And this allows double-barrelled words with hyphens

  • SQL query help with CASE

    Hi All,
    I have 2 tables like below. now i have a requirement which i need to do it in CASE OR DECODE. because i have to implement this logic IN SELECT STATEMENT for a column.
    In table T1 if Lang = 1 and State = 'P' then display Lang = 'english' in table T2(which is Lang=2 in table T1) Or else display null.
    Can we do this logic using CASE or DECODE? pls help
    T1
    Lang  State
    1      P
    2      N
    T2
    Lang  Dscr
    1     central
    2     english

    Something like this ?
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t1 AS (SELECT 1 lang, 'P' STATE FROM DUAL UNION ALL
      2              SELECT 2 lang, 'N' STATE FROM DUAL
      3             )
      4     , t2 AS (SELECT 1 lang, 'central' dscr FROM DUAL UNION ALL
      5              SELECT 2 lang, 'english' dscr FROM DUAL
      6             )
      7  SELECT t1.lang,t1.state,CASE
      8           WHEN t1.lang=1 AND t1.state='P'
      9           THEN (SELECT t2.lang FROM t2 WHERE dscr='english')
    10           ELSE NULL
    11           END "lang"
    12* FROM t1
    SQL> /
          LANG S       lang
             1 P          2
             2 N

  • Help with Regular Expressions and regexp_replace

    Oh great Oracle Guru can I can gets some help
    I need to clean up the phone numbers that have been entered in Oracle eBusiness per_phones table. Some of the phone numbers have dashes, some have spaces and some have char. I would just like to take all the digits out and then re-format the number.
    Ex.
    914-123-1234 .. output (914) 123-1234
    9141231234 ..again (914) 123-1234
    914 123 1234 .. (914) 123-1234
    myphone ... just null
    (914)-123-1234.. (914) 123-1234
    I really tried to understand the regular expressions statments, but for some reason I just can't understand it.

    Hi,
    Welcome to the forum!
    I would create a user-defined function for this. I expect there will be a lot of exceptions to the regular rules (for example, strings that do not contain exactly 10 digits, such as '1-800-987-6543') that can be handled, but would require lots of nested fucntions and othwer complicted code if you had to do it in a single statement.
    If you really want to do it with a regular expression:
    SELECT     phone_txt
    ,     REGEXP_REPLACE ( phone_txt
                     , '^\D*'          || -- 0 or more non-digits at the beginning of the string
                           '(\d\d\d)'     || -- \1 = 3 consecutive digits
                    '\D*'          || -- 0 or more non-digits
                           '(\d\d\d)'     || -- \2 = 3 consecutive digits
                    '\D*'          || -- 0 or more non-digits
                           '(\d\d\d)'     || -- \3 = 4 consecutive digits
                    '\D*$'             -- 0 or more non-digits at the end of the string
                     , '(\1) \2-\3'
                     )          AS new_phone_txt
    FROM    table_x
    ;

Maybe you are looking for