Help with CASE

Hello people.
TABLE PHONECALLS FIELDS: EMP_ID, TELNO, COST, TYPE
TYPE can be DATA or VOICE
1 EMP_ID owns more than 1 TELNO
I need a report with the following columns:
EMP_ID, TELNO, VOICE_COST, DATA_COST
I need something like:
SELECT EMP_ID , TELNO, SUM(COST),
SUM(CASE COST WHEN TYPE = DATE THEN ...... END) AS VOICE,
SUM(CASE COST WHEN TYPE = VOICE ...... END) AS DATA
FROM PHONECALLS
GROUP BY EMP_ID, TELNO
ORDER BY EMP_ID ASC;Thank you in advance.

Something like this?
SELECT EMP_ID , TELNO, SUM(COST),
SUM(CASE TYPE WHEN 'DATE' THEN COST END) AS VOICE,
SUM(CASE TYPE WHEN 'VOICE' THEN COST END) AS DATA
FROM PHONECALLS
GROUP BY EMP_ID, TELNO
ORDER BY EMP_ID ASC;Or the alternative way of using CASE:
SELECT EMP_ID , TELNO, SUM(COST),
SUM(CASE WHEN TYPE = 'DATE' THEN COST END) AS VOICE,
SUM(CASE WHEN TYPE = 'VOICE' THEN COST END) AS DATA
FROM PHONECALLS
GROUP BY EMP_ID, TELNO
ORDER BY EMP_ID ASC;The first use of CASE is simple - the other can have as complex expressions as needed ;-)

Similar Messages

  • 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.

  • 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

  • Still need help with case sensitive strings

    Hello guy! Sorry to trouble you with the same problem again,
    but i still need help!
    "I am trying to create a scrypt that will compare a String
    with an editable text that the user should type to match that
    String. I was able to do that, but the problem is that is not case
    sensitive, even with the adobe help telling me that strings are
    case sensitive. Do you guys know how to make that comparison match
    only if all the field has the right upper and lower case letters?
    on exitframe
    if field "t:texto1" = "Residencial Serra Verde"then
    go to next
    end if
    end
    |----> thats the one Im using!"
    There were 2 replys but both of them didnt work, and the
    second one even made the director crash, corrupting even previously
    files that had nothing to do with the initial problem..
    first solution given --
    If you put each item that you are comparing into a list, it
    magically
    makes it case sensitive. Just put list brackets around each
    item.
    on exitframe
    if [field "t:texto1"] = ["Residencial Serra Verde"] then
    go to next
    end if
    end
    Second solution given--
    The = operator is not case-sensitive when used on strings,
    but the < and > operators are case-sensitive.
    So another way to do this is to check if the string is
    neither greater than nor less than the target string:
    vExpected = "Residencial Serra Verde"
    vInput = field "t:texto 1"
    if vExpected < vInput then
    -- ignore
    else if vExpected > vInput then
    -- ignore
    else
    -- vExpected is a case-sensitive match for vInput
    go next
    end if
    So any new solutions??
    Thanks in advance!!
    joao rsm

    The first solution does in fact work and is probably the most
    efficient way
    of doing it. You can verify that it works by starting with a
    new director
    movie and adding a field named "t:texto1" into the cast with
    the text
    "Residencial Serra Verde" in the field. Next type the
    following command in
    the message window and press Enter
    put [field "t:texto1"] = ["Residencial Serra Verde"]
    You will see it return 1 which means True. Next, make the R
    in the field
    lower case and execute the command in the message window, it
    will return 0
    (true).
    Now that you know this works, you need to dig deeper in your
    code to find
    what the problem is. Any more info you can supply?

  • Help with case suggestion

    I need the searching power of the Apple Community, for my efforts have produced few results!
    I was a blackberry user (the 8310 Curve) and I really liked the case I had. Leather case, magnetic strap, swivel clip and I was able to pull the phone out whenever I needed to.
    I am trying to find something similar if not exactly like this for the iphone. Slim is nice, but I really want that swivel clip so that I can angle the case and pull out the phone whenever i need too. (I see some cases have a strap overtop)
    Any suggestions are greatly appreciated.

    It depends on your budget. I plumped for one of these http://www.vajacases.com/ as i've had them in the past and the quality is top notch. However, I couldn't decide between two different ones so I also went with one of these as well and i'll chop & change as & when I feel like a change. I couldn't resist as they look so cool http://www.miniot.com/miniot/index.htm
    I also like the blackberry cases, however, i've found that the belt clip doesn't last all that long. One has broken on me and the second one is on it's way out now. The first option from vaja sounds more like what you are looking for though. Hope this helps.

  • Need help with case cracking - Defect?

    I have a macbook (white) a1181 that I purchased in 2008...
    I handle my computers very delicatly and if they travel with me, they are packed very well with support...
    The body (case) of the laptop back by the fan underneath has a long hairline crack.
    There is also one where the front lip is as well.
    NOW,
    Apple Genius Bar wants ME to pay outright to get it fixed.
    It was not my fault at all!!!!! And it was not accidental damage either.
    SO I called Apple who wouldn't help me because I don't have phone support Or apple care. So if I pay the $50 for phone support, they'll tell me the same thing they told me in the store the operator told me.
    FIRST OFF, I didn't know that my Apple Care expired and even if I had it, it wouldn't really help me I was told...
    I paid so much money for this laptop and scrimped and saved up and I feel like I'm being dragged through the mud.
    I need to contact someone higher-up ASAP - this is absolutely ridiculous.
    I did not do anything to cause this cracking..
    I am so upset as I really saved up for years for this computer only for 3-4 years later for it to be cracking worse and worse. I paid so much...
    Any advice or help would be greatly appreciated.
    Thanks,
    aj

    ajsonnick wrote:
    I need to contact someone higher-up ASAP - this is absolutely ridiculous.
    Did you ask to speak to a manager while you were at the Apple store?

  • Help with case issues in Java 1.3

    Using JDK 1.3 and Windows 98... here is my problem. If I create a class called EventSite.java and another class called eventsite.java (same name, different cases) and then compile them both...I only see the the first class compiled in the directory (they are both being compiled into the same directory).
    i.e. I run 'javac EventSite.java' and when I look in the c:\jdk1_3\bin\ directory I see EventSite.class.
    I then run 'javac eventsite.java' and when I look in the same directory I only see EventSite.class. Why???????
    Where did eventsite.class go?
    Note: both .java files compile without error.
    Help please.

    The problem is that Java is case sensitive but Windows is not. So the files get replaced. You have to avoid using this kind of naming under Windows. Besides it doesn't make much sense.

  • 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

  • Help with case number :0185603779 not resolved.  Can someone please help me??????????????

    I have Adobe Digital Edition 2.0 on my computer.  I am receiving a message that it has stopped working.
    I had contacted Adobe previously, but the issue was not resolved.  Can you please help me?????????????

    I concur with dwb's assessment. See:
    Mac Maintenance Quick Assist,
    Mac OS X speed FAQ,
    Speeding up Macs,
    Macintosh OS X Routine Maintenance,
    Essential Mac Maintenance: Get set up,
    Essential Mac Maintenance: Rev up your routines,
    Maintaining OS X, 
    Five Mac maintenance myths, and
    Myths of required versus not required maintenance for Mac OS X for information.

  • Help with Case Usage or similar

    Has anybody tried using similar to below case usage in where clause. Is there any other way i can get this done.
    To summarize the query, month starts from 7th of current month to 6th of next month. Query has to dynamically assume that. Please let me know.
    Thanks ahead for assistance.
    select * from table tc
    where tc.column=x and
    (case when (to_char(sysdate, 'DD')/7)>=1 THEN
    trunc(tc.CREATED_DATE) between to_date('07-'||to_char(sysdate, 'MM-YYYY'), 'DD-MM-YYYY') and
    to_date('06-'||to_char(add_months(sysdate, 1), 'MM-YYYY'), 'DD-MM-YYYY')
    else
    trunc(tc.CREATED_DATE) between to_date('07-'||to_char(add_months(sysdate, -1), 'MM-YYYY'), 'DD-MM-YYYY') and
    to_date('06-'||to_char(sysdate, 'MM-YYYY'), 'DD-MM-YYYY')
    END)

    I missed a piece of the calculation. I tried the below query with Aug 6th and 7th. It should work for any day - including SYSDATE;
    SQL> with tc as (
       select trunc(sysdate -60 + rownum) created_date
       from dual
       connect by rownum <= 100)  
    select *
    from tc
    where created_date between trunc(to_date('06-AUG-07','DD-MON-YY')-6,'MM')+6
                           and trunc(add_months(to_date('06-AUG-07','DD-MON-YY')-6,1),'MM')+5
    CREATED_DATE
    07-JUL-07  
    08-JUL-07  
    05-AUG-07  
    06-AUG-07  
    31 rows selected.
    SQL> with tc as (
       select trunc(sysdate -60 + rownum) created_date
       from dual
       connect by rownum <= 100)  
    select *
    from tc
    where created_date between trunc(to_date('07-AUG-07','DD-MON-YY')-6,'MM')+6
                           and trunc(add_months(to_date('07-AUG-07','DD-MON-YY')-6,1),'MM')+5
    CREATED_DATE
    07-AUG-07  
    08-AUG-07  
    05-SEP-07  
    06-SEP-07  
    31 rows selected.

  • Help with case structure

    In the VI that i'm enclosing, i have used a boolean array of two booleans to operate two case structures. Inside the case structure, when the boolean is true the shift register value is to be incremented once.The difference between the two incremented values is taken as count. I am facing two problems, firstly, the increment takes place continously instead of just once every time the boolean is true, secondly, the count switches to zero when the switch is turned back to false.
    Thanks in advance.
    Attachments:
    New.vi ‏11 KB

    Try something like this.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    NewMODCA.vi ‏8 KB

  • Need help with case/mount

    I'm looking for something to hold my iPhone in the glove box of my BMW. Thx

    I use an older fourth gen iPod in my BMW and always leave it in the glove box. I found the original Apple iPod semi-hard case with belt clip that used to come with iPods at that time.(no such accessories included these days unfortunately) I have my iPod safetly inside it inside the glove box. In that case it does not roll around.
    I think you can still but these cases zt Apple stores. Else something like that type of case to protect the iPod would be all you need.

  • Need help with case when

    Create global temporary table d_desc1
    ( discrep_id NUMBER
    ,desc_1 VARCHAR2(110)
    Create global temporary table d_desc2
    ( discrep_id NUMBER
    ,desc_2 VARCHAR2(110)
    INSERT INTO
    d_desc1
    SELECT distinct
    d.discrep_id
    ,NVL(dd.discrep_desc,'') as desc_1
    FROM
    discrep_ d
    ,discrep_desc_ dd
    WHERE
    d.discrep_id = dd.discrep_id
    AND dd.DISCREP_DESC_SEQUENCE = 1
    AND dd.html_ind <> 'Y'
    AND dd.discrep_desc <> '<br>'
    AND dd.discrep_desc NOT LIKE '<font Class=%'
    AND d.discrep_id in (915606255, 879868258, 826503010, 824812060)
    AND d.discrep_date >= '01-jan-2009'
    AND d.discrep_date <= to_date('31-jan-2009')+1;
    INSERT INTO
    d_desc2
    SELECT distinct
    d.discrep_id
    ,case when d1.discrep_id = dd.discrep_id then d1.desc_1 || '' || dd.discrep_desc
    when d1.discrep_id <> dd.discrep_id then dd.discrep_desc as desc_2
    FROM
    discrep_ d
    ,discrep_desc_ dd
    WHERE
    d.discrep_id = dd.discrep_id
    AND dd.DISCREP_DESC_SEQUENCE = 2
    AND dd.html_ind <> 'Y'
    AND dd.discrep_desc <> '<br>'
    AND dd.discrep_desc NOT LIKE '<font Class=%'
    AND d.discrep_id IN (915606255, 879868258, 826503010, 824812060)
    AND d.discrep_date >= '01-jan-2009'
    AND d.discrep_date <= to_date('31-jan-2009')+1;
    CREATE TABLE DISCREP_
    (     DISCREP_ID NUMBER,
         DISCREP_DATE DATE, )
    CREATE TABLE DISCREP_DESC_
    (     DISCREP_ID NUMBER,
         DISCREP_DESC_SEQUENCE NUMBER ,
         DISCREP_DESC_DATE DATE ,
         DISCREP_DESC NVARCHAR2(100) ,
         HTML_IND CHAR(1 BYTE) ,
         PERSON_ID NUMBER
    discrep_desc for a given discrep_id can have several discrep_desc_sequence for the same date. I need to put them on one line and be able to query it by discrep_id to update a column in another table with the data. I don't plan to use global temporary tables in my procedure for this but to test it for now I am using them. the case statement is giving me d1.desc_1 || '' || dd.discrep_desc and dd.discrep_desc for a given discrep_id instead of just dd.discrep_desc if the discrep_id isn't in d_desc1 and d1.desc_1 || '' || dd.discrep_desc if the discrep_id is in both tables. the first insert should give you 3 rows and the second insert should only give you 3. 826503010 is only in d_desc2 and 879868258 is only in d_desc1. if you know of a loop or anything else that might work better please give me an idea how to write it. I am using oracle 10g.
    thanks.

    figured out myself. Thanks.

  • Need help with case.

    Hi,
    I have spent since Sunday playing phone tag in regrades to my case. I called yesterday and explaned everything about my case to a supervisior and was told it would be handled and I would receive points to my account for $25.00. I was not given a case number, but was told it was put into the system. So far, nothing was been resolved. I am losing faith and patience in this and need some help.
    Thanks
    Chris

    Hello Seminole30-
    Welcome to Best Buy Unboxed! We appreciate your patience in receiving the point adjustment on your MyBestBuy account.
    Using the email address you used to register onto the forum, I was able to find the pending fund. It looks like everything is in order and your fund is being processed accordingly. To the best of my knowledge, a fund can take up to 5 business days after the fund was issued to reflect on your MyBestBuy account.
    Thank you for your time,
    Karina|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Need help with case structures- please help :)

    Hey all.
    I'm currently trying to program a infrared furnace. I'm setting a temperature, subtracted my set temperature from the actual temperature (thermocouple hooked up to SCB-68), and voltage is being sent to the controller of the furnace accordingly. However, I need to hold the set temperature for a certain amount of time. I need help programming this: when the VI reads the set temperature from the thermocouple, it results in a timer running down. When the timer runs down to 0, the While Loop ends. I'm thinking case structures is most appropriate, but if you have a better suggestion, please let me know.
    Thanks

    You should probably implement a state machine.
    The state machine would keep track of the temperature and making ajustments on a timely basis.
    There is a template of a state machine is you select under the File menu > New > From Template.
    You can also look under Help > Find Example > and do a search for state machine.
    There are lots of state machine examples on this forum, some of which may be quite useful.
    RayR

Maybe you are looking for