He had to find the way of the table based on conditions...

Hello

Please look at the specimen below...
 
AMOUNT      ID NO             Date
          
588     0000053125     07/01/09
612     0000053125     06/01/09
528     0000053125     05/01/09
635     0000053125     04/01/09
700     0000053125     04/02/09
588     0000053126     07/01/09
612     0000053126     06/01/09
528     0000053126     05/01/09
635     0000053126     04/01/09
700     0000053126     04/02/09
588     0000053127     07/01/09
612     0000053127     06/01/09
528     0000053127     05/01/09
635     0000053127     04/01/09
700     0000053127     04/02/09
588     0000053128     07/01/09
612     0000053128     06/01/09
I need to know the average of (AMOUNT) of the last three months, based on the given ID no..
Please note that for the registration of the sample, there are only 3 ID no.... but in real time will come more ID no..

Note:
ID no. 0000053128 is to have only two recordings... here, the average should be calculated accordingly.

Hello!

It should provide AVG ol 3 last records (assuming that you have in your data in a record for a month)

SELECT id_no, AVG(amount)
   FROM (SELECT amount, id_no, date1, row_number() over(PARTITION BY id_no ORDER BY date1 DESC) rn
                FROM Your_table ORDER BY id_no, date1 DESC )
WHERE rn <= 3 GROUP BY id_no

T

Tags: Database

Similar Questions

  • Find the table of characters on my computer if it is not in the accessory file

    I write a scientific article for the school and could not find the table of characters on my computer.  I looked in Accessories - System Tools and nothing.  I should I reinstall or at least find a site online that will show you the appropriate key strokes to get what I'm looking for

    Hello

    Start - type in the search box-> find the table of characters at the top of list - double click it to run it.

    You can also right click and COPY then PASTE an icon on the desktop or the start menu.

    I hope this helps.

    Rob Brown - MS MVP - Windows Desktop Experience: Bike - Mark Twain said it right.

  • Find the table number B &gt; = number in the table but &lt; then next entry b

    I'm trying to understand the following: find the table number B > = number in the table but < then next entry b

    Table A

    5
    10
    21
    20

    Table B

    8
    12
    16
    23
    40

    The 5 entry in table A, I would like to return 8 b
    For the 10 entry I would lke to return 12 b
    21 entry I would like to return 23 b
    20 entry I would like to return 23 b

    Edited by: Withnoe October 5, 2012 09:19

    Edited by: Withnoe October 5, 2012 10:54

    CREATE TABLE TAB_A (CLASS # VARCHAR2 (10), THE NUMBER OF TERM);
    CREATE TABLE TAB_B (CLASS # VARCHAR2 (10), THE NUMBER OF TERM);

    INSERT INTO TAB_A VALUES ('BIOL 520', 201010);
    INSERT INTO TAB_A VALUES ('BIOL 521', 201250);
    INSERT INTO TAB_A VALUES ('BIOL 522', 200980);

    INSERT INTO TAB_B VALUES ('BIOL 520', 201110);
    INSERT INTO TAB_B VALUES ('BIOL 520', 201150);
    INSERT INTO TAB_B VALUES ('BIOL 520', 201250);
    INSERT INTO TAB_B VALUES ('BIOL 521', 201250);
    INSERT INTO TAB_B VALUES ('BIOL 521', 201260);

    SELECT MIN (TAB_B.TERM) TERM, TAB_B.CLASS # TO TAB_A, TAB_B
    WHERE TAB_A.CLASS # = TAB_B.CLASS #.
    AND TAB_B.TERM > TAB_A.TERM
    GROUP TAB_B.CLASS #;

    Please let us know if you need anything else. Thank you

  • How to find the table in a schema, if I only have a particular column name

    Hi all

    Ideal if some1 could help me, I know not a column name and I need to find the table that actually holds this column paricular name I know.

    is it possible to find this particular table with SQL?

    Thank you
    Rahul

    Select the table TABLE_NAME from user_tab_columns where column_name = 'COLUMN_NAME '.

  • Startup Repair... He had to find the product key

    Got a Vista computer that starts in the startup repair all the time no matter what, even in safe mode. I click on this pagehttp://grab.by/7Sse and nothing works to be able to reformat the computer.

    Fortunately, I got the Vista installation DVD, but the only problem is I cannot find the product key for it, is there an easy way to get it back? I live Linux disks so I can do it like that. I tried a few programs through wine and neither work.

    These are the programs I've tried under wine on Fedora:

    http://www.NirSoft.NET/utils/product_cd_key_viewer.html

    http://www.magicaljellybean.com/KeyFinder/

    Any help is appreciated in trying to extract the thanks :) product keys

    Hi Banjo348,

    Method 1: You can follow the steps mentioned in the article below and check if this solves the problem

    Windows Vista or Windows 7 unbootable and the Startup Repair tool does not resolve the problem
    http://support.Microsoft.com/kb/934540

    If the problem persists, contact the computer manufacturer

    About the product key, please see the article below

    How to identify, locate, and replace a product key
    http://support.Microsoft.com/kb/811224

    To replace a Microsoft product key, contact Microsoft and support Customer Service.
    http://support.Microsoft.com/default.aspx?scid=fh; EN-US; CNTACTMS

    Important note: This thread contains a reference to third party World Wide Web site. Microsoft does not control these sites and no has not tested any software or information found on these sites; Therefore, Microsoft cannot make any approach to quality, security or the ability of a software or information that are there. There are the dangers inherent in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Thanks and greetings

    Ajay K

    Microsoft Answers Support Engineer
    ---------------------------------------------------------------------------------------------------------
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • We had to find the date in the format "DD-MM-YYYY" and "DD/MM/YYYY '.

    Hello world

    I need to find the hire_date in the format "dd-mm-yyyy" and "dd/mm/yyyy '. This shows also some errors, I can't found. pls help to solve this problem...

    Hello

    Christine Schnittker says:
    ... It works as well:

    SQL> select to_date('22-02-2012','dd/mm/yyyy') dt from dual;
    
    DT
    ----------
    22-02-2012
    

    (Does anyone know anything that actually says?)

    The Manual of the SQL language , after listing the format items allowed in TO_DATE, says the following:

    Any nonalphanumeric character is allowed to match punctuation characters in the format model. For example, the following statement returns no error:
    SELECT TO_CHAR (TO_DATE('02#07','MM/YY'), ' MM/YY') FROM DUAL;

    TO_CH
    -----
    02/07

  • Find the device based on serial number

    Hi all

    I got a spot on place to locate the Cisco gear in our (hundreds of them), got the serial number but wonder if there is a smart way to find out where is this piece? rather than 'show version' on each device, then look for the serial number. Please teach me. Thank you very much.

    Hi Duke,

    Thank you for using the Cisco Small Business forums. My name is Cristian, I'm a developer of electronic content, and I'm part of the small community of business support.

    Unfortunately, I don't know of a method where you can directly find the device via the serial number. However, I know that Cisco's FindIT uses the CDP of Cisco protocol to detect Cisco devices in a network. You could hover over with the mouse device names and the serial number will be displayed.

    I hope that this response will be useful, and I hope that you respond with questions or concerns.

    * Please answer question mark or note the fact other users can benefit from the TI *.

    Kind regards

    Cristian Gonzalez

    EContent Cisco Developer

  • Try to find the table of Directors of a group of fabric (EnterpriseAdminGroups)

    Hello

    I'm not having much luck finding a way to determine the list of users in the "fabric administrators' shown in VRA (VCAC) using a script in VCO.  Does anyone have any idea on how I can do to get the table of users?


    I was able to do with groups of companies:

    var groups = vCACCAFEEntitiesFinder.getBusinessGroups (vCACHost);

    for {(i in groups)

    System.Debug ("groups [" + i + "] =" + groups [i]);

    var = Admins groups [i] .administrators;

    }

    I'm so looking for something similar, but related to EnterpriseAdminGroups, which does not have the property of "Administrators".

    So far I only have this code, which is not having me administrators:

    entities var = vCACEntityManager.readModelEntitiesByCustomFilter (vCACHost.id, "ManagementModelEntities.svc", "EnterpriseAdminGroups", null, null);

    System.log ("Enterprise Admin groups found:" + entities.length);

    var prop = new Properties ();

    for each {(entity in entities var)

    System.Debug ("\n\nentity:" + entity);

    Prop.put (Entity.GetProperty ("adminname"));

    }

    Thank you!

    OK, I think I finally thought to it.  GetFabricGroupAdminByVirtualMachine (vCAC:VCACHost vCACHost, vCACCAFE:VCACHost vCACCAFEHost, vCAC:VirtualMachine virtualMachine) is created.  The method returns a string value of the user name found an admin of fabric for one of the groups of fabric for the computing resource that belongs to the virtual computer.

    Here is the code:

    If (! vCACHost) {}

    throw "Missing vCACHost (vCAC:VCACHost);

    }

    If (! vCACCAFEHost) {}

    throw "Missing vCACCAFEHost (vCACCAFE:VCACHost);

    }

    If (! virtualMachine) {}

    throw "Missing virtualMachine (vCAC:VirtualMachine);

    }

    var vchost = virtualMachine.getEntity () .getLink (vCACHost, 'Host') [0];

    var fabricGroups = vchost.getLink (vCACHost, 'EnterpriseAdminGroups');

    var tenantName = vCACCAFEHost.tenant;

    var authorClient = vCACCAFEHost.createAuthorizationClient ();

    var authorPrincipalSvc = authorClient.getAuthorizationPrincipalService ();

    var currPage = 1;

    numPages var = 1;

    var maxItemsPerPage = 25;

    loop through each page

    While (currPage<= numpages)="">

    var page = new vCACCAFEPageOdataRequest (currPage, maxItemsPerPage);

    var princExtResult = authorPrincipalSvc.getPrincipalExtensions (tenantName, page);

    updating with the number of pages received

    numPages = princExtResult.getMetadata () .getTotalPages ();

    for (var i in {princExtResult.getContent ())}

    var princExt = princExtResult.getContent ([i]);

    var spans = princExt.getScopes ();

    for {(var j in spans)

    var range = extended [j];

    for (k fabricGroups) {}

    {If (scope.getName () = {fabricGroups [k] .getProperty ('AdminName'))}

    var scopeRoles = scope.getPrincipalScopeRole ();

    for (var x in scopeRoles) {}

    If (scopeRoles [x] .getName () = "Company administrator") {}

    found a fabric admin

    System.Debug ("found fabric group admin:" + princExt.getDisplayName ());

    Return princExt.getDisplayName ();

    }

    }

    }

    }

    }

    }

    currPage ++;

    }

    no users found

    Returns a null value.

  • How to find the tables that are used in a procedure

    Hello
    I need to write a SQL to find (user_source) procedures or triggers (from user_triggers), whose code contains the registerd tables in a table X.
    In other words, I have a table X with files having a column containing tables. I want to write a SQL to obtain these (proc, package and triggers) container objects or use the tables inside
    Can you help me?
    Thank you!

    Mark1970 wrote:
    Hello
    I need to write a SQL to find (user_source) procedures or triggers (from user_triggers), whose code contains the registerd tables in a table X.
    In other words, I have a table X with files having a column containing tables. I want to write a SQL to obtain these (proc, package and triggers) container objects or use the tables inside
    Can you help me?
    Thank you!

    I don't know if I understand your problem, but have you had a glance at the data dictionary views USER_DEPENDENCIES or ALL_DEPENDENCIES?

    It has classified hard dependencies of objects.
    If a table is used directly (not in dynamic SQL code in a string) in an object PL/SQL, the dependency is available in the stated points of view.

  • How to find the table - is - this normal table or external table?

    Hello


    Regardless of DML operations in normal and reading tables only access tables outside, is there a way to find the specified table is regular table or the external table?

    Thanks in advance.

    Suresh.

    One possibility would be to query the ALL_EXTERNAL_TABLES data dictionary view. If there is a line in ALL_EXTERNAL_TABLES to the table, wondering (I assume you know that you query a table, a view, or a synonym), it is an external table. Otherwise, it's an ordinary table.

    Justin

  • How to find the table?

    Hello

    I have a java Apps to connect to a database of GR 11, 2.
    When I clicked on a "billing" module, I don't 'a number' 1,641.00 error in java logs that cause billing does not be generated.
    I don't even enter this value. I don't know if this error at the level of the table or during analysis on the coast of java it fetch a numeric variable placeholder.
    I simply assume that it is at the database level. And assuming that I am the only user in the database.
    How can I get this operation with the 1,641.00 value and determine which table was is inserted to the error? In V$ SQLAREA maybe?
    SYSUSER - 263293-40-1 2012-07-10 11:08:25,578 [http-6700-1] INFO  (support.context.CacheManager) Registering cache 'BusinessObjectInfoCache'
    SYSUSER - 263293-41-1 2012-07-10 11:08:25,859 [http-6700-2] ERROR (api.service.ServiceExecutionPolicy) Rollback: Read failed
    java.lang.NumberFormatException: Not a number: 1,641.00
         at com.ibm.icu.math.BigDecimal.bad(BigDecimal.java:3894)
    Thank you very much
    Kins

    >
    apps itself has no problem.
    >
    I have to disagree. If the application is to throw an exception and the journal contains her not the information necessary for you tell what is causing the exception, and then the application has ALSO a problem.

    java.lang.NumberFormatException: Not a number: 1,641.00
         at com.ibm.icu.math.BigDecimal.bad(BigDecimal.java:3894)
    

    Add additional record to the app to catch the exception and discover the connection, the request and the record that causes the error.

    Troubleshoot, to gather information when the problem actually occurs and work your way backwards.

    If you say that the problem did not exist before the developer made the change then prove it by running the old code against the same data. If it works then the problem is with the change that made the developer.

  • cannot find the table name of the multiple tables which has more columns.

    Hello

    I'm trying to find the NAME of the TABLE from multiple tables which has more columns. I can't count the number of columns in the table, but cannot find the name of the table that has larger columns in other tables.

    SELECT TABLE_NAME, COUNT (*) FROM THE USER_TAB_COLUMNS WHERE TABLE_NAME LIKE '% LOC' GROUP TABLE_NAME


    Thank you.

    in SQL, you can try this:

    var v_name varchar2(40)
    
    begin
       with
          subq1 as ( select table_name, count(*) as column_count from user_tab_columns where table_name like 'FIBER%'
                         group by table_name
                         order by count(*) desc )
       select table_name
         into :v_name
        from subq1
       where rownum = 1;
    end;
    

    To get the result:

    select :v_name from dual
    

    The clause "with" brings together all the tables and ordered them all first, by the greatest number of columns
    The final query uses the rownum restriction so that it takes the first name from the table of results of the subquery.

    The restriction of rownum also exactly guarantees a result each time so that it will work with the variable binding.

    RP

  • How to find the tables placed only on pages.

    Hi experts,

    I find all the tables in the document (no XML Indd file.) .indd There is only a certain number of tables. And a table in the master page also. Now I'm trying to get back only the tables except the master page. How can I got it?

    I used the following code. But it is not working properly.

    var myTables is app.activeDocument.stories.everyItem () .tables;.

    App.Select(mytables[0]);

    var myTableCount = myTables.length;

    Alert (myTableCount);

    for (var i = 0; i < myTableCount; i ++) {}

    var myTableObj = myTables [i];

    Alert (myTableObj.parent);

    Try

    {

    var myTableObj.parent.parentPage.name = XXX;

    If (xxx.match("^[0-9]+$"))

    {

    Alert ('table');

    myTableObj.label = 'table' +(i+1);

    }

    on the other

    {

    Alert ("Master Page table");

    }

    }

    catch (e)

    {

    Alert (e.message);

    }

    }

    Always throw catch loop...

    Can someone guide me...!

    Thank you and best regards,

    Vel.

    Hi Peter,.

    Finally, I close with the codes below. It make me fight a lot...

    var pagelen = app.activeDocument.pages.length;

    Alert (pagelen);

    for (var i = 0; i)<>

    {

    var pageitemlen = app.activeDocument.pages [i].pageItems.length;

    for (var j = 0; j)<>

    {

    v var = app.activeDocument.pages [i] .pageItems [j] .tables;

    Alert (v.Length);

    for (var x = 0; x)<>

    {

    App.Select (v [x]);                                                      Here, I can select.

    App.Selection [0] .label = "table" + count;

    Count ++;

    myTables.push (v [i]);

    }

    }

    }

    Peter, thank you very much for your time in Golden for my problem...

    With respect,

    Vel.

  • Not able to find the tables of IOM

    Hi xperts.
    I use OIM9101 and sql developer to access the db. I created a connection, but when I'm looking the IOM tables, I'm not able to find a... just the tables précréé

    Any help...

    Mahi

    Then its fairly simple. Connect with username = oimuser and password = everything you used during installation

    But if its still throw an error, then you need either by putting the wrong password. It confirms once more

    Thank you

    Sunny

  • Restrict the records in the CSV, based on condition

    Greetings. I searched the forum for my problem and have not found an answer or the right search terms. I'm under APEX 4.1.1

    I have a report on a page. I show all the records to a SQL query given in my table, but in the 'export to CSV' I need limit the output based on one of the fields. Thus, for example, if I had a report such as:

    SELECT x, y, Z
    FROM Table1

    I would like to export to CSV format for this table to limit the output such as:

    SELECT x, y, Z
    FROM Table1
    WHERE Z = 1

    Is this possible?

    Thank you!
    John

    Hi John,.

    I tested the connection now and works above for interactive report only and for the classic report, you need to do something like that because the demand is set to a different value

    SELECT x, y, Z
    FROM Table1
    WHERE ((Z = 1 and nvl(:REQUEST,'X') like 'FLOW_EXCEL_OUTPUT%') OR nvl(:REQUEST,'X') not like 'FLOW_EXCEL_OUTPUT%')
    

    See this example of work http://apex.oracle.com/pls/apex/f?p=46417:25

    When you export to CSV you'll get 10 dept records

Maybe you are looking for