Select with average cal

Hi all
I have 3 fields with numeric values in a table.
How can I make the average to the values to zero?
Example:
10 20 30 = 60/3 = 20
10 0 20 = 30/2 = 15 - divided by two, because one of the values is equal to zero.
0 6 0 = 6/1 = 6
I can probably make a case statement for a long time, but I wonder if it's a better way.
Thanks in advance
with t as (
           select 10 col1,20 col2,30 col3 from dual union all
           select 10,0,20 from dual union all
           select 0,6,0 from dual
          )
select  (nvl(col1,0) + nvl(col2,0) + nvl(col3,0)) / (sign(abs(nvl(col1,0))) + sign(abs(nvl(col2,0))) + sign(abs(nvl(col3,0)))) avg
  from  t
/

       AVG
----------
        20
        15
         6
SQL> 

SY.

Tags: Database

Similar Questions

  • Issue of license; need information on the purchase of Windows Server 2008 R2 with 25 CAL

    I am looking to buy Windows Server 2008 R2 with 25 CAL.  The question I ask myself, is that if I were to continue this RDS would come with the initial 25 CAL or it would cost more.  If so, how much per RDS? and how much would cost the package for the Windows Server 2008 R2 with 25 RDS CAL company.

    Thanks in advance

    Hello

    Post your question in the TechNet Server Forums, as your question kindly is beyond the scope of these Forums.

    http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

    See you soon.

  • Can we synchronize permission selected with the settings of operating system Notifications BB10 for our Application.

    Steps to follow:
    BB10 device--> settings--> Notifications--> Applications--> [name of your application]--> all alerts [Toggle button]

    I have an obligation to check whether or not 'All alerts' is allowed through settings when the application is running. To check if we can synchronize permission selected with the settings of operating system Notifications BB10 for my application. How to get javascript code if alerts permission is on / off, while the application is running.

    I tried adding the blackberry.system function and tried to hasPermission (blackberry.push) also, I can't determine if permission is allow / prohibit... Please suggest how to get that.

    I don't see a WebWorks API for this. If I expected to be anywhere, it's here:
    https://developer.BlackBerry.com/HTML5/APIs/beta/BlackBerry.notification.html#jbo1385148829097

    But it seems that this API has not been fully implemented; It may be useful to connect a developer Issue Tracker JIRA to get this feature added.

    At the same time, there is this API of Cascades that looks like what you're looking for:
    https://developer.BlackBerry.com/native/reference/Cascades/bb__platform__notificationapplicationsett...

    Write an extension for this feature should allow you to access this feature:
    https://github.com/BlackBerry/WebWorks-community-APIs/tree/master/BB10-Cordova/template

    At the same time, a colleague is currently working on an extension that should open many features of Qt, and I think that the API above should be accessible through this extension. He must be released over the next week or two, so you can wait for that as well.

    EDIT: On this last point, see this extension which provides a mechanism for attaching in the majority of the Qt APIs.

    https://github.com/BlackBerry/WebWorks-community-APIs/tree/master/BB10-Cordova/QtBridge

  • SELECT with many setting set SQLite (> 200)

    Hello

    I have an exception when I run a simple SELECT with 220 parameters:

    Statement st = mSQLiteDatabase.createStatement ("SELECT name, UserId FROM myTable WHERE UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? OR UserId =? ») ;

    If I execute the same statement with 10 settings for example, there were no problems!

    Is this another limitation of implementation of Blackberry?

    Thanks in advance.

    You can try this IN operator

    Statement st = mSQLiteDatabase.createStatement ("SELECT name, UserId FROM myTable WHERE UserId in (UserId, UserId, UserId, UserId,... UserId);")

    Note: This is not tested in the Sqlite database.

    But successfully performed in the other RDatabase.

    Thank you

    ------------------------------------------------------------------------------------
    Kudo press to say thank you to the developer.
    Also, press accept it as a button when you got the Solution.

  • BlackBerry Smartphones Syncronization of calendar with google cal bb

    I would like to know that if it is possible to synchronize my blackberry directly with google cal, without going threw outlook? And if so, how?

    Thank you...

    You can use google sync

    You can use Google mobile for contacts and calendar synchronization

    http://www.google.com/mobile/blackberry/sync.html in pc

    http://m.google.com/sync in blackberry

  • I need a box multi select drop-down list or list of selection with image or icon faclitliy

    Hello

    I tried to find a plugin or a jquery plugin that allows to perform the task of

    have a list of selection with images and there should be a facility such as multi select.

    How this can be accomplished. One have they implemented it in any of their application

    Any information will be greatly appreciated.

    Thank you

    pauljohny100 wrote:

    Hello

    I tried to find a plugin or a jquery plugin that allows to perform the task of

    have a list of selection with images and there should be a facility such as multi select.

    How this can be accomplished. One have they implemented it in any of their application

    Any information will be greatly appreciated.

    When ask questions user interface-related still State (at least) the full version of APEX, the theme and the version of browser compatibility / required.

    See the plugin jQuery Select2 , for which there is a plug in APEX .

    Pre-plugin when we have implemented requirements like this using a model report, CSS and personal...

  • Photoshop: image becomes black when you try to select with inclusive

    image becomes black when you try to select with inclusive

    (edited)

    Powering the OpenGL in the Performance preference and restarting Photoshop have no bearing on the question?

  • Multiple selection with binding variable error

    Hello world

    I tried to put in place an array of adf multiple selection with another table, by following the tutorial (http://www.oracle.com/technetwork/developer-tools/adf/learnmore/75-multi-parent-row-detail-views-328078.pdf), page 3.

    I created all things and first of all I had an exception error, which I fixed, but now, whenever I try to select multiple lines, it won't update the table of the adf.

    In this example, I choose a service line and it shows the emplooyes, but every time I try to choose another line by ctrl clicking on it, the employees table be updated.

    Since I tryied to follow the tutorial, I'll put the code for the bean, I created for this purpose (it's a little different than the code given by the tutorial, but only because I had to get rid of the exception error)

    I use jdeveloper Studio Edition Version 12.1.2.0.0.

    Here is my code for the bean.java:

    Select listen port defined for the departments table. The selected line keys are read in the reference table.

    For each line, the Department ID value is read and added to a string buffer that generates a comma-delimited

    List of the departmentIds. In the end, this string is passed as an argument to the link of action ExecuteWithParams

    {} public void onDepartmentTableSelect (SelectionEvent selectionEvent)

    variable to hold the string containing the selected set value line departmentId

    StringBuffer departmentIds = new StringBuffer();

    Go to the main table to read selected line keys

    RicheTableau rt = selectionEvent.getSource ((richeTableau));

    RKS RowKeySet = rt.getSelectedRowKeys ();

    Iterator selectedRowsIterator = rks.iterator ();

    memorize the current line to place it back in the end key

    CurrentRowKey () rt.getRowKey = (list);

    for each selected master line, determine the departmentId

    int size = 0;

    {while (selectedRowsIterator.hasNext ())}

    size ++;

    The rowKey () selectedRowsIterator.next = (list);

    each value is terminated by a comma

    If (departmentIds.length () > 0) {}

    departmentIds.append(",");

    }

    take the current line

    rt.setRowKey (rowKey);

    JUCtrlHierNodeBinding wrappedRow = rt.getRowData ((JUCtrlHierNodeBinding));

    Line rw = wrappedRow.getRow ();

    /*

    Number departmentId = (number) rw.getAttribute ("DepartmentId");

    */

    int departmentIdInt = rw.getAttribute ("DepartmentId") (Integer);

    oracle.jbo.domain.Number departmentId = new oracle.jbo.domain.Number (departmentIdInt);

    departmentIds.append (departmentId.stringValue ());

    }

    back the foreign currency on the line

    rt.setRowKey (currentRowKey);

    Run the query on the detail table

    BindingContext bctx = BindingContext.getCurrent ();

    BindingContainer links = bctx.getCurrentBindingsEntry ();

    OperationBinding executeWithParams = bindings.getOperationBinding("ExecuteWithParams");

    executeWithParams.getParamsMap () .put ("departmentIds", departmentIds.toString ());

    executeWithParams.execute ();

    refresh the detail table

    AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance ();

    adfFacesContext.addPartialTarget (employeeTable);

    }

    }

    If someone has an idea of why it isn't updated table, please answer. Any idea can help.

    Thanks in advance.

    Greetings,

    Frederico Barracha.

    Finally, I found the problem...

    The problem was that I had to remove a line in the properties of my table, the property services: selectedrowkeys, because he only spent the last selected row.

    Yet, I apreciate the help and I had to replace a code in the bean.java, in reason of the exception error and you had to do. Maybe I did a configuration in the wrong way and he would not.

    Thanks for the help.

    Kind regards

    Frederico.

  • Unable to set keyframes in the audio clip selected with the pen tool - can no longer see the volume control line after developing the clip. What could be the problem? This seems to be the problem on any project that I opened.

    Cannot set keyframes in the audio clip selected with the pen tool - cannot see even the line volume control more to set keyframes on having developed the clip. What could be the problem?  I use the first CC pro @.

    You can use the Ctrl key and then click with the regular selection tool, clicking with ctrl will make a new keyframe. in this way, have no need for the tools. CTRL has other great shortcuts that will stop you having to spend retouching pads tools too.

    If the automation keyframe line is missing, you can switch on and off in the menu sequence.

  • The Central handle on the rectangle isn't gone when I select with the black arrow (v) tool. See the bounding box and the edges is both. Dd intermediate anchor to go?

    The Central handle on the rectangle isn't gone when I select with the black arrow (v) tool. See the bounding box and the edges is both. Dd intermediate anchor to go?

    haggyabeken,

    I'm afraid that you have come across the Rectangle Live bug, which is limited to MAC versions starting from 10.7 and 10.8, but not 10.9 (Mavericks), see this thread linked below.

    https://forums.Adobe.com/thread/1595973

    Thus, a switch for the Mavericks with a reinstall might be the way to solve it here and now.

    To get around it, in each case, it is possible to develop direct Rectangles to get the normal old shaped rectangles or Pathfinder > unit, or use the scale tool.

    A more permanent way round that is to create normal old shaped rectangles, after running the free script created by Pawel, see this thread with download link:

    https://forums.Adobe.com/thread/1587587

  • Why a quick selection is clear my selection with second click?

    I click the selection with my quick selection tool and then when I click again to continue to select more, the second begins to remove my current selection. I know now removes it key 'option' my selection but I don't hold the key 'option '. It starts just do it when I do my second click and continues then withdraw even if I continue to click. I've just updated Photoshop but that did not help. I have Photoshop CC. Help, please.

    This is probably caused by you after clicking on the button "Subtract from selection" at some point in time, in the settings of the tool, see photo. If you have no selection when you start using the tool, it will create one, but as soon as there is an active selection tool will begin to subtract. Each tool of the PS remember its settings! As suggested by Pierre, reset your tool will solve this problem or just by clicking on the button "new selection". It can be a pretty good idea to reset your tools, the first thing you do every day a new working session in order to avoid such problems when starting.

  • Select with LESS vs two VARRAYS with MULTISET

    Hi all

    I just wanted to know, which one of the two following is faster and results in better performance.

    1. SELECT statement containing 200 + columns in a Table with operator LESS. (TWO SELECTS with operator between them LESS)

    2. loading of the individual SELECT statement (with some LESS) result sets in two different VARRAYS and then use these two operators of type MULTISET.

    That one is faster and uses less memeory?

    Thank you
    REDA

    Direct SQL is still fast compared to the PLSQL. When you use varrays, there will be change of context. Even if you use Bulk collect for loading data yu have to put a limit of 1000 and not beyond.

  • make a selection with an alias

    I have a lot of images which have been made out of 3DS MAX. A long time ago that I recorded an action to do an alpha channel, use it as a mask and save it as 2 different file types. Worked very well. Now, I need to open a bunch of them and somehow, get rid of the anti aliasing around the image. I need jaged edge. I did some how in the past using threshold (I think), but can't for the life of me what I've done. Any ideas on how to make a selection with an alias?

    Thank you

    Dean

    You have an alpha channel, which has levels of grey in it?

    Simply use the threshold on this alpha channel.

    -Christmas

  • White on white selection with the magic wand of refining

    I'm trying to remove the background of a picture of BW - one model posing in front of a white background.

    Select with the magic wand works fine except on the area where the light on the model wears the white skin. When I choose, I get the hand and the lower part of the arm (see below) but miss the box top, completely white. I tried all kinds of settings and also tried to increase the contrast with a brightness/contrast layer, but nothing I I understand allows me to keep the arm and remove the bottom with the arm.  FWIW, the image cannot be redone.

    How can I do? Thanks for any help.

    EdB

    fist copy.jpg

    Learn how masking... Also in white when mixed in a layer with the blending mode multiply does not change.  So, if you add a new layer on top of your image and set its blending mode to multiply. You will see your arm starts to show through. Add a maske layer to this layer and paint with black to show the lower arm of the layer by hiding the top layer on the arm area.

  • Select with the DATE WHERE the...

    Hi all!

    I need to select with where condition on cirtain cust_date date (date) specifying columns say date01 = 25 August 10 'and time range somewhere between time01 = 7:15:00 ' and time2 = 9:30:00 ' ('HH24:MI:SS).
    I have some test data and I saw still some trouble with my select particular regarinding of time slot.

    Can someone tell me what will be the easiest way to do this, especially for the begiinner;

    SELECT * FROM TABLE1 WHERE cust_date > to_date (August 25, 2010 7:15:00 ',' DD-MON-YY HH24:MI:SS')...

    I just do to_date after >?


    TX
    Trent

    Trento wrote:
    Hi all!

    I need to select with where condition on cirtain cust_date date (date) specifying columns say date01 = 25 August 10 'and time range somewhere between time01 = 7:15:00 ' and time2 = 9:30:00 ' ('HH24:MI:SS).
    I have some test data and I saw still some trouble with my select particular regarinding of time slot.

    Can someone tell me what will be the easiest way to do this, especially for the begiinner;

    SELECT * FROM TABLE1 WHERE cust_date > to_date (August 25, 2010 7:15:00 ',' DD-MON-YY HH24:MI:SS')...

    I just do to_date after >?

    TX
    Trent

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/functions183.htm#SQLRF06132

    Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.7.0
    Connected as SYS
    
    SQL> desc SH.SALES
    Name          Type         Nullable Default Comments
    ------------- ------------ -------- ------- -------------------------------------------------------------------------------------------
    PROD_ID       NUMBER                        FK to the products dimension table
    CUST_ID       NUMBER                        FK to the customers dimension table
    TIME_ID       DATE                          FK to the times dimension table
    CHANNEL_ID    NUMBER                        FK to the channels dimension table
    PROMO_ID      NUMBER                        promotion identifier, without FK constraint (intentionally) to show outer join optimization
    QUANTITY_SOLD NUMBER(10,2)                  product quantity sold with the transaction
    AMOUNT_SOLD   NUMBER(10,2)                  invoiced amount to the customer                                                             
    
    SQL>
    SQL> SELECT *
      2  FROM SH.SALES S
      3  WHERE S.TIME_ID >= to_date('19970102','YYYYMMDD')
      4  AND ROWNUM < 4
      5  ;
    
       PROD_ID    CUST_ID TIME_ID     CHANNEL_ID   PROMO_ID QUANTITY_SOLD  AMOUNT_SOLD
    ---------- ---------- ----------- ---------- ---------- ------------- ------------
            37        368 01/01/1998           2        999          1.00        63.57
            37       4687 01/01/1998           2        999          1.00        63.57
            37       8302 01/01/1998           2        999          1.00        63.57
    SQL>  SELECT *
      2  FROM SH.SALES S
      3  WHERE S.TIME_ID >= to_date('19970102 10:12:00','YYYYMMDD HH24:MI:SS')
      4  AND S.TIME_ID < to_date('20000102 10:12:00','YYYYMMDD HH24:MI:SS')
      5  AND ROWNUM < 4
      6  ;
    
       PROD_ID    CUST_ID TIME_ID     CHANNEL_ID   PROMO_ID QUANTITY_SOLD  AMOUNT_SOLD
    ---------- ---------- ----------- ---------- ---------- ------------- ------------
            37        368 01/01/1998           2        999          1.00        63.57
            37       4687 01/01/1998           2        999          1.00        63.57
            37       8302 01/01/1998           2        999          1.00        63.57
    
    SQL> 
    
    SQL>
    SQL>  SELECT *
      2  FROM SH.SALES S
      3  WHERE S.TIME_ID >= to_date('January 15, 1989, 11:00:00','Month dd, YYYY, HH:MI:SS',
      4       'NLS_DATE_LANGUAGE = American')
      5  AND S.TIME_ID < to_date('January 15, 2000, 11:00:00','Month dd, YYYY, HH:MI:SS',
      6       'NLS_DATE_LANGUAGE = American')
      7  AND ROWNUM < 4
      8  ;
    
       PROD_ID    CUST_ID TIME_ID     CHANNEL_ID   PROMO_ID QUANTITY_SOLD  AMOUNT_SOLD
    ---------- ---------- ----------- ---------- ---------- ------------- ------------
            37        368 01/01/1998           2        999          1.00        63.57
            37       4687 01/01/1998           2        999          1.00        63.57
            37       8302 01/01/1998           2        999          1.00        63.57
    
    SQL>
    SQL> SELECT *
      2  FROM SH.SALES S
      3  WHERE S.TIME_ID >= to_date('14-Feb-1998 11:00:00','DD-Mon-YYYY HH24:MI:SS',
      4       'NLS_DATE_LANGUAGE = American')
      5  AND S.TIME_ID < to_date('17-Mar-2000 11:00:00','DD-Mon-YYYY HH24:MI:SS',
      6       'NLS_DATE_LANGUAGE = American')
      7  AND ROWNUM < 4
      8  ;
    
       PROD_ID    CUST_ID TIME_ID     CHANNEL_ID   PROMO_ID QUANTITY_SOLD  AMOUNT_SOLD
    ---------- ---------- ----------- ---------- ---------- ------------- ------------
            36       2168 15/02/1998           3        999          1.00        51.29
            36       7237 15/02/1998           3        999          1.00        51.29
            36       7678 15/02/1998           3        999          1.00        51.29
    
    SQL>  
    

Maybe you are looking for

  • Upgrade to the Mavericks without new installation Mountain Lion?

    Hi guys,. I'm looking to upgrade my Mac to the Mavericks Mountain Lion (I do not want to Yosemite or El Capitan again that not all my software is fully compatible), but I was wondering if it was possible to not have to do a clean install, but just up

  • Pavilion DV6-2113AX: lack of series of Windows

    Hello I bought the laptop in September 2010. I did the recovery discs for Windows but now after so many years, these discs have deteriorated and I couldn't use them to recover my system. I tried to find the key to series or something for Windows, but

  • Installation of LV 2011, VISA stop working

    I've been using LV2010 since he was released on a project. Everything worked very well. Friday, I installed LV2011 and the PDA I use stop responding. His love is not yet in the system. I upgraded to LV2011 on a different project and the Palestinian n

  • HP envy m6-1125dx: install new fresh windows 10

    Dear HP support, I'm a client that you currently use product, I have a question that must be resolved.  I have a windows OEM 8 laptop which is HP ENVY M6-1125DX I mentioned in my name of the product and since the new windows 10 just came out a few da

  • Analog for U2711 max resolution 2048 x 1152

    I have just bought a U2711 and cannot do run at no more than 2048 x 1152 from windows 7.  The highest resolutions are only available via the DVI connections. It will only work at 1920 x 1080 to a MACbook pro or IMAC, even through the DVI connection I