Summing at run time in a select

Hi There,
My table with data is like this
Salesrep                            dealid          revenue    yr      qtr
[email protected]               sr123          1000       2012    1
[email protected]               sr124           150        2012     1
[email protected]               sr125           3150        2012     2
[email protected]               sr126           200         2012      1
.I want to get the sum of the revenue by sales rep based on the condition that the revenues are added where revenue is between 0 - 1000 "small", 1001 - 2000 "Medium", > 2001 "Large"
so output will be something like
[email protected] 1150 small, 0 medium, 3150 large
[email protected] 200 small, 0 medium, 0 large
Can we do this in a select?
Thanks,
Sun

Something like this:
WITH temp AS
  ( SELECT 1250 revenue FROM DUAL
  UNION ALL
  SELECT 2000 FROM DUAL
  UNION ALL
  SELECT 5500 FROM DUAL
  UNION ALL
  SELECT 1600 FROM DUAL
  UNION ALL
  SELECT 900 FROM DUAL
SELECT
  CASE
    WHEN revenue BETWEEN 0 AND 1000
    THEN revenue ||' '||'Small'
    WHEN revenue BETWEEN 1001 AND 2000
    THEN revenue ||' '||'Medium'
    WHEN revenue > 2000
    THEN revenue||' '||'Large'
  END output
FROM TEMP;
OUTPUT                                         
1250 Medium                                    
2000 Medium                                    
5500 Large                                     
1600 Medium                                    
900 Small    

Similar Messages

  • Run time error when select large field

    My code is:
    #define WIN32COMMON
    #include "stdio.h"
    #include <occi.h>
    #include <string>
    using namespace oracle::occi;
    using namespace std;
    int main()
         try
              //init env
              Environment *env = Environment::createEnvironment(Environment::THREADED_MUTEXED);
              //create connection
              Connection *conn = env->createConnection("system","password","to_o10g_db");
              //create sql statement
              Statement *stmt_insert =NULL;
              char intstr[6];
              string sql_str = string("insert into test_table_t values('name") + string("1' ,'value1')");
              printf("Execute 10000 times insert operation.\n");
              for(int i=0;i<10000;i++)
                   itoa(i, intstr, 10);
                   sql_str = string("insert into tang_test_t values('name")
                        + intstr
                             + string("','value")
                             + intstr
                             + string(" ')");
                   stmt_insert= conn->createStatement(sql_str);
                   stmt_insert->executeQuery();
                   conn->terminateStatement(stmt_insert);
              printf("Finished 10000 times insert operation.\n");
              Statement stmt = conn->createStatement("SELECT FROM tang_test_t");
              ResultSet *rs = stmt->executeQuery();
              //read record
              while(rs->next()) // when get 15 records ,raise error !!!!!!!!!!!!!! WHY????
                   printf("The Record is %s,%s.\n",rs->getString(1).c_str(),rs->getString(2).c_str());
              stmt->closeResultSet(rs);
              conn->terminateStatement(stmt);
              env->terminateConnection(conn);
              Environment::terminateEnvironment(env);
         catch(SQLException &e)
              printf(e.what());
         return 0;
    Who can help me? Thanks.

    What is the error '!!!!!!!!!'? Can you please be more clear? Thanks.

  • Sum of running times in spreadsheet

    I am trying to figure out if times for a runner can be calculated and averaged in Pages? Any suggestions since I am new to Pages. Thanks!

    Tim,
    Yes, you can do the calculation in a Pages Table. I wouldn't work out the solution there though. The equation management and editing tools just seem easier in Numbers. When you're done and like the result in Numbers, you can copy the table to Pages and use it there if you like, but I'm not sure I can see an advantage to moving to Pages.
    Jerry

  • Run time for a Report

    Hi All,
    I have a requirement, where in i want to know whether my report has run for 8 mins or not. If it has run for 8 mins then i have to give an information message saying that the report is taking more than 8 mins so schedule the program in back ground.
    Is this possible ?
    Please let me know how to know during run time the time taken by a report.
    Regards
    Rakesh.

    Hi Dominic,
    The code you mentioned can be put to know what is the time taken by a select statement or the time taken by a particular piece of code. In my program there are several select queries and complex logics.. So i dont think that it is feesible to calculate the run time for each select and then if its increasing 8 mins then to show error !!!!
    My report will be called from an external application. If the program is taking much time it will get timed out. So for a precaution we have to tell them that the way you have given the selection screen filter values its going to take more than 8 mins so better schedule a back ground job.

  • How To... Change the Data Type for a SELECT-OPTIONS at run time.

    Hello,
    I am trying to restrict the values available for entry into a SELECT-OPTIONS at run time depending on user input.
    The logic is as follows. The user has two input fields. A PARAMETER field which has the type RSDIOBJNM and allows them to choose an InfoObject. And the user has a SELECT-OPTIONS field to allow them to select the Characteristic values for that InfoObject.
    I would like the following example to be possible:
    The user enters 0MATERIAL into the PARAMETER. When the user clicks on the SELECT-OPTIONS control code will derive a list of possible options the user can enter in the SELECT-OPTIONS. In this case only values found in the master data or at least no values greater than 18 characters.
    I have looked at the following function module SELECT_OPTIONS_RESTRICT and this do not appear to be helpful as they only restrict on the signs allowed for the values (unless I misunderstand, it is a complex function module!).
    The code I have so far is (thus the user enters a InfoObject into p_char1 and the select options so_char1 should only accept active values of that InfoObject):
    declaration of variables for user interface
      DATA c_char(32) TYPE c.
    declaration of count variable
      DATA i_count TYPE i.
    declaration of user interface
      SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
        PARAMETERS: p_ipack TYPE RSLOGDPID.
      SELECTION-SCREEN END OF BLOCK a1.
      SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-002.
        PARAMETERS: p_char1 TYPE RSDIOBJNM.
        SELECT-OPTIONS: so_char1  for c_char NO INTERVALS.
        PARAMETERS: p_char2 TYPE RSDIOBJNM.
        SELECT-OPTIONS: so_char2  for c_char NO INTERVALS.
        PARAMETERS: p_char3 TYPE RSDIOBJNM.
        SELECT-OPTIONS: so_char3  for c_char NO INTERVALS.
      SELECTION-SCREEN END OF BLOCK b1.
    Is what I am trying to do possible???
    Thanks for any help. Ross.

    You really want to restrict possible values of a select-option based on another field, not change the length of type of the select-option field, right?
    Here is what you do:  Code a custom F4 value help for the select-option at event AT SELECTION-SCREEN ON VALUE REQUEST FOR..  The first thing you do here is read the value of the parameter field (p_ipack in your example).  You can use function module DYNP_VALUES_READ.  Based on this value, you can propose values for the select-option fields.  Note that the use can still enter whatever s(he) wishes in to the select-option field without pressing F4. In this case, you will have to code some input validations taking into account the value in the p_ipack field.

  • Select serial comm port in sub vi during run-time

    Hi, would like to be able to select the comm port (serial RS232) in sub vi to use in main vi during run time. How can I do this? Have tried and failed, for on startup an error occurs because I have not selected a port yet. An example would be invaluable! Thanks alot, Madri

    Hi Madri !
    What you could do is to intercept the com errors, and open a configuration vi either if there is an init error or if the user has pressed a "Change port" boollean (or menu...). Do not forget to close the previously opened serial port, and to open/init the new one. I have attached a small example of this idea.
    Of course com errors can have various origins, and do not require always to change the serial port. So, you have some additional work to do.
    Hope this helps
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Select_port.vi.zip ‏12 KB
    Com_with_serial_init_vi.vi.zip ‏13 KB

  • How to select a sub image in run time

    Hi ,
    how can i select sub image from an image on panel in run time ?
    OR
    how to draw a rectangle(with dashed lines) on the panel and from its dimension i'll get the sub image ?
    THANKS

    BufferedImage.getSubImage(....);

  • Select Template at run time?

    I have a site that contains content for multiple languages.
    Each
    language currently has it's own set of templates and this
    works well in
    conjunction with Contribute.
    However, some page are shared between the different
    languages, usually
    those containing ASP.NET code.
    To cut a long question short, is it possible to determine
    which template
    should be used by a page when that page is viewed in the
    browser? I have
    a script that creates a variable contain a value of the
    browser language
    or read a pre-defined language value from a cookie. I'd
    really like to
    use this variable to dynamically force a page to use a
    specific template.
    e.g. say have 2 templates: us.aspx.dwt and fra.aspx.dwt. can
    I influence
    the following line (from a page using a specific template) to
    select the
    template at run time?
    <!-- InstanceBegin template="/Templates/us.dwt.aspx"
    codeOutsideHTMLIsLocked="false" -->

    No. DW templates only work inside DW. They are strictly
    design-time tools
    that affect only local files.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Kevin Blount" <[email protected]> wrote in
    message
    news:ebdl6s$huh$[email protected]..
    >I have a site that contains content for multiple
    languages. Each language
    >currently has it's own set of templates and this works
    well in conjunction
    >with Contribute.
    >
    > However, some page are shared between the different
    languages, usually
    > those containing ASP.NET code.
    >
    > To cut a long question short, is it possible to
    determine which template
    > should be used by a page when that page is viewed in the
    browser? I have a
    > script that creates a variable contain a value of the
    browser language or
    > read a pre-defined language value from a cookie. I'd
    really like to use
    > this variable to dynamically force a page to use a
    specific template.
    >
    > e.g. say have 2 templates: us.aspx.dwt and fra.aspx.dwt.
    can I influence
    > the following line (from a page using a specific
    template) to select the
    > template at run time?
    > <!-- InstanceBegin template="/Templates/us.dwt.aspx"
    > codeOutsideHTMLIsLocked="false" -->

  • No 'order by' selection for cluster tables generates run-time

    Hi together,
    Basically I want to use a "select...order by" statement with table mhnd.
    Since mhnd is a cluster table you can not use "...order by".
    So, I use a select ... into table. I then sort this table and finally read it (index = 1)
    Unfortunatly this approach generates huge run-time.
    What can be done to minimize run-time?
    Thanks for any help

    Hi Gerd,
    Which cluster table you are using and what`s data you wanted? Maybe there are some FM to extract data from it.
    regards,
    Archer

  • Run time error when clicking on sum button

    Hi,
        I have used a field (data type-QUAN,length-10,Decimal Places-3)
    in an internal table. I have passed this table in 'REUSE_ALV_GRID_DISPLAY'.
        When I wan to see the 'sum' by clicking the button on the application tool bar , There is always a run time error.
        Please help as quick as possible.
    Regards,
    Sourav Paul.

    Hi,
    try following,
    DATA: GT_EVENTS TYPE SLIS_T_EVENT.
    INITIALIZATION.
    PERFORM BUILD_EVENTS CHANGING GT_EVENTS.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
               IT_EVENTS          = GT_EVENTS[]
        TABLES
          T_OUTTAB           = IFINAL.
    ENDFORM.                    " display_output
    FORM BUILD_EVENTS CHANGING GT_EVENTS TYPE SLIS_T_EVENT.
      DATA: LINE_EVENT TYPE SLIS_ALV_EVENT.
      CLEAR LINE_EVENT.
      LINE_EVENT-NAME = 'TOP_OF_PAGE'.
      LINE_EVENT-FORM = 'TOP_OF_PAGE'.
      APPEND LINE_EVENT TO GT_EVENTS.
    ENDFORM.                    "build_events
    Reward pts if usefull.
    Regards,
    Dhan

  • Run-time error 5097 on Selection.InsertFile in Word 2013 macro

    We have been running Word 2003 macros to generate large volumes of document files for 10+ years.
    Now running the same code using Word 2013, we are getting Run-time error '5097' on this line of code:
    Selection.InsertFile filename:=pFileName
    We have over 40 code sets that potentially call in 20,000+ Word document files. 98% of the time this code will work; but several files will not insert when this code attempts to execute.
    Any ideas?
    Thanks,
    Dawn Cox

    Hi Dawn,
    Thanks for the detail information for this issue.
    Since the file even can't be inserted manually, this issue is not relative to the code. To get more effective response, I would suggest that you reopen a new thread in
    Microsoft Community- Word or
    TechNet- Word forum.
    And to help other communities to narrow this issue, I also suggest that you provide a sample file for testing.
    Hope it is helpful.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How do i get the data present in the selected row at run time in Multicolumn list box?

    Hi,
    I am using multicolumn list box with three columns and i am having OK button.
    If the user selects particular row and then press ok then that row datas(that 3 values) has to get update in the file.
    Can u tell me how to get that selected row values alone and also how to append the list box value at run time?
    Thanks
    Meenatchi

    You can simply use the Value property of the MLBox to get the row selected & wire it to the Delete from array function with the Itemnames of the MLBox as the Input & Output of the Delate from array function.
    See the attached VI.
    - Partha
    LabVIEW - Wires that catch bugs!
    Attachments:
    Dbl-click Row to get Data & Delete.vi ‏41 KB

  • Find Unicode for selected Symbol at run time

    Hi,
    I have one InDesign document which is having lots of Symbols with applied font Symbol Medium.
    While manually selecting the perticular symbol  we can find the releted Unicode in Glyphs.
    But I want to do this task by using script means I want to find the unicode for perticular selected symbol at run time without any manual intervention.
    please help me out.
    Regards,
    Raj

    Hi Jongware
    thanks for reply,
    as you mentioned  app.selection[0].contents.charCodeAt(0) is giving only the unicode value of Special caracters like emSpace, EnSpace, NewLine, etc.
    But we are expecting unicode of characters like µ (Unicode: 00B5) , λ (Uncode: 03BB).

  • Selection screen list box with run time values

    Hi,
    I have to create a selection screen list box with with values at run time.
    This is actually for a maintanence view.
    Please help.
    Thanks
    Vimalraj

    Have a search in SDN and elsewhere for the function module 'VRM_SET_VALUES'... for example there's one at:
    Re: Listbox with Function code in Table control
    wherein the 2nd listbox contents are driven from the option selected in the first listbox.
    Jonathan

  • Run time Error while executing project infosystem reports (CN41/41N)

    Hi,
    I would like to inform while running project infosystems reports (CN41/41N / cns41 etc), it is taking long time & most of the time run time errors are coming. I observed due to more objects in projects, run time error is coming. Request you to suggest to fix the issue.
    Thank you for your cooperation.
    Regards,
    Rakesh Pradhan

    Hi Rakesh,
    The memory which can be managed by the logical database is approx.       
    100 MB. You can use the following rule of thumb to calculate the         
    allocated memory of your selection:                                                                               
    [(  sum of projectdefinitions + sum of WBS elements + sum of networks and orders ) * 1 KB  + ( sum of activities     ) * 4 KB ] *2,5 = memory consumption                                                                               
    Further objects - as relationships, capacities, ... will increase        
    the memory consumption. (see note 107605) 
    You can find out the number of objects bein used using the "Test selection scope" (CTRL+F12) button in CN41                                                                               
    Other recommendations are:                                                                               
    1) Check the profile (parameter "rdisp/PG_MAXFS") with your Basis        
       colleague and adjust upwards (Note 133909)                                                                               
    2) Select a smaller range of objects by using status schema              
       or more dynamic selections. Please review SAP Note 206264.                                                                               
    3) Please review also 107605, which gives you further information 
       concerning the selection in Project Information System.                                                                               
    Hope this helps!
    Regards
    Martina
    Message was edited by:
            Martina Modolell

Maybe you are looking for

  • Mixing a 1GB memory (DDR3 1067Mhz) with a 4gb (DDR3 1333MHZ)

    hi there i currently have 2gb (2x1) ddr3 1067mhz on my macbook pro. I'm thinking of upgrading it to 5gb, so I would take off one of the 1gb memories and insert a 4gb one. problem (?) is, the 1gb memory is 1067 and the 4gb one is 1333. when I asked th

  • ICloud and photo stream not working

    icloud will not allow photostream. It said I need the newest iphoto. I just bought my mac over the summer with lion. It says it is 9.1.5 and I need 9.2. I tried to system update and checked the app store but nothing will let me update it. ***?

  • Why do my headphones only play out of right ear when they're perfectly fine?

    my headphones were working fine last night but this morning when I went to listen to music they would only work out of right ear. If anyone knows the solution to this please let me know

  • Dropdown list in interactive form

    Hello All, I want to get a drop down list in adobe interactive form. I did the following. 1. created a simple dictionary data type and populated it with values 2. created a context and bound it to the simple dictionary type. 3. when I drag the elemen

  • I am unable to open a Zip file I downloaded.

    I play an online golf game at www.wgt.com and to help my playng I downloaded an app from www.wgt.4fan.cz it is WGT Caddy PRO. I am unable to open the file. From reading the answers to other questions concerning opening Zip files, I downloaded Unarchi