View previous transactions in the table citywise

Hi all

I have about 2 million transactions in the table of MEASURES. There are thousands of transactions of the cities. I want to return 40 first operations (datewise orderded I mean first transactions when a city was presented in the table) of each city, there are close to 100 cities in the table. Can all help modify the SQL code following it please?
select citycode,cityname, actiondate, performedaction
from ACTIONS
where performedaction=6 and citycode in (select citycode from cities where description is not null)
order by 2,3 asc
I would appreciate your help in this regard.

Thank you

Try this

SELECT citycode
      ,cityname
      ,actiondate
      ,performedaction
  FROM (SELECT a.*
              ,ROW_NUMBER () OVER (PARTITION BY cityname ORDER BY actiondate) row_num
          FROM actions             a
              ,cities              c
         WHERE performedaction     = 6
           AND a.citycode          = c.citycode
           AND c.description       IS NOT NULL
       )
 WHERE row_num <= 40
 ORDER BY 2,3 ASC

Concerning
Arun

Tags: Database

Similar Questions

  • I want to get the property of the previous object in the table

    Hello

    Here is my code

    for (var i in {MovieClip (root) .arrySpt)}

    var btn:MovieClip = MovieClip (box);

    duplicate the movielcip (add a new scene)

    var ClassDefinition: Class = Class (getDefinitionByName (getQualifiedClassName (btn)));

    var myMC:MovieClip = new ClassDefinition;

    myMC.inBin.text = MovieClip (root) .arrySpt [i];

    trace (getChildByName("myMCC"+i_as_String).width);

    myMC.x = i * myMC.width;

    myMC.y = 0;

    myMC.velocityY = 0;

    box.addChild (myMC);

    Box.Boxin.Visible = false;

    }

    var myMC:MovieClip = new ClassDefinition;

    Movieclips here create a this line of code ND is the allocation of the post

    myMC.x = i * myMC.width;


    Here the width is the attribution to the X position of the object in progress, but I want to assign width X position to the object following unusual object. Average if movieclip generate it should get the previous movieclip of the table width.


    Please help me solve this problem.


    Thank you

    use:

    var prevX:int = 0;

    for (var i in {MovieClip (root) .arrySpt)}

    var btn:MovieClip = MovieClip (box);

    duplicate the movielcip (add a new scene)

    var ClassDefinition: Class = Class (getDefinitionByName (getQualifiedClassName (btn)));

    var myMC:MovieClip = new ClassDefinition;

    myMC.inBin.text = MovieClip (root) .arrySpt [i];

    trace (getChildByName("myMCC"+i_as_String).width);

    myMC.x = prevX;

    prevX += myMC.width;

    myMC.y = 0;

    myMC.velocityY = 0;

    box.addChild (myMC);

    Box.Boxin.Visible = false;

    }

  • Dreamweaver CS5, MySQL, PHP: Why the views are listed under the tables in connection

    Using Dreamweaver C5 on a remote server with MySQL and PHP, I notifce the opinion that I defined in the database are the list under tables in the login window, not under views. Probably does not really matter, but I was wondering if there is a way to influence this - keeping views listed separately in the tables.

    Hello

    This has to do with how MySQL stores the view in the database, (a similar problem occurs with procedures) that they are stored as part of the entire database.

    View on there own are not natively supported in dreamweaver.

    PZ

  • Define a view that refers to the tables of 50?

    Hello

    I have a problem at hand, and I'm not sure what I can adopt the right solution.

    There is a demand which has just hit the DB (v11.2) to access a single view "XVIEW. This view has a simple sql & join that is based on two tables XTABLE1 and XTABLE2.

    Now, the new version of the schema that has been released has split XTABLE2 into 50 paintings different each with the same structure. For the correction of the question, there are two solutions I could think:

    1. create 50 views above 50 paintings and difficulty of enforcement to designate these 50 new views. Note: the app has hundreds of references and it has an important work involved.

    2 rewrite XVIEW refer to 50 paintings. You can avoid so modify the application, however I do not know if this is feasible and will have a decent performance.

    I would go for solution 2, because it requires a lot less effort, but do not know how to set the view, only the 50 table structure is the same that I can just union of them?

    Thanks for the help.

    Hello

    Hozy says:
    Frank, thank you for help out me.

    What you are proposing is that I should recreate the XVIEW view what union did all (as the lines will be unique) 50 paintings, however performance will be a problem unless I can create a materialized views.

    I know of materialized views, what it is used for static pre-calculated data type.

    A materialized view is pre calculated; This is what makes it faster. The time and effort spent, in doing so, the UNION is moved from the moment you make queries at the same time when you refresh the materialized view. If it's more or less total time depends on how many times you query the view and how often you refresh. In any case, the performance when you perform them queries will be as good as possible.
    Views materialized ar often used in data wharehouses, where then can only change once a month, but they are also often used in situations like yours, when data changes on a daily basis, or even more frequently.

    In my case, the little 50 tables data can change once every 24 hours and all this comes at some point. Queries that hit XVIEW should obtain the most recent data. Is there a way I can define a materialized view that will pick up the new data in the base tables 50?

    I see it; you have some job that turns to, say, 02:00 every morning and changes some, or perhaps all, 50 tables. You can refresh the materialized view to, say, 04:00 daily, or at some point, when you are sure that the changes made to the tables of the Basic are completed. Any query that uses the view materialized between 02:00 and 04:00 will get outdated data.
    Otherwise, you could do the materilaized view Refresh whenever one of these base tables changes, but it uses more resources, including your time and effort to set up.

  • SQL to bring the last line and the just previous row in the table

    Hi all

    I have a table of orders, where a serial number can be booked with different number several times over several days.

    Requirement is to bring the last order (based on the date of creation) number associated with this serial number and just previous order number and data in the format below.

    Last order numberSerial numberReservation locationNo bookingPrevious order numberSerial numberReservation locationNo booking

    It is essentially to generate the report that a reserved serial number with how many times with different orders and report must contain details of order two in a line.

    Kind regards

    You asked for the last line, and you have not provided data of the example or the expected results, so you get what you asked for.

    You may be looking for data to be partitioned on another value, for example

    SQL > ed
    A written file afiedt.buf

    1. Select deptno, ename, empno, mgr, hiredate, prev_empno, prev_ename, prev_mgr, prev_hiredate
    2 starting at)
    3. Select deptno, ename, empno, mgr, hiredate
    lag (empno) 4, over (partition by deptno arrested by hiredate) as prev_empno
    lag (ename) 5, over (partition by deptno arrested by hiredate) as prev_ename
    lag (mgr) 6, over (partition by deptno arrested by hiredate) as prev_mgr
    lag (hiredate) 7, over (partition by deptno arrested by hiredate) as prev_hiredate
    8, case when hiredate = max (hiredate) on (deptno partition) then 1 0 otherwise fine as max_hiredate
    9 of PEM
    10       )
    11 * where max_hiredate = 1
    12.

    DEPTNO EMPNO, ENAME MGR HIREDATE PREV_EMPNO PREV_ENAME PREV_MGR PREV_HIRED
    ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
    10 7934 MILLER 23/01/1982 7782, 7839 KING 17/11/1981
    20 7876 ADAMS 7788 23/05/1987 7788 SCOTT 7566 04/19/1987
    30 7900 JAMES 7698 03/12/1981 7654 MARTIN 7698 28/09/1981

    who is the last disc, by Department, as well as the previous within the same Department.

  • Hi, I want to drag and drop a file in the form (in a grid view of data in the table of attachments in database-type access is incidental)

    I am using visual basic 2010. A shape has a datagridview named in an attachment that is connected to a binding source (access database) named attachments. The columns are attached and description. The attachment is not of type text, this is the type of attachment. How to download files in the access database by using my VB form.

    Can anyone suggest me how do. I'm new to VB. It'll be good if you can provide the code.

    Hello

    Your question is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the MSDN Developer audience. Please ask your question in the following forum.

    VB general forum:
    http://social.msdn.Microsoft.com/forums/en-us/vbgeneral/threads

    Concerning

  • Try to download again CS6 creative cloud. My creative cloud application will show all previous versions of the applications.

    I'm trying to download Encore CS6 creative cloud. When I filter the apps to view previous versions of the programs, "Edge animate CC" and "Gaming SDK" are the only apps that appear. I guess there are many more previous versions of apps that should appear, including Encore CS6. I just updated my creative cloud application. My co-workers have also updated their app CC, but they are able to download CS6 still very well the 'previous versions' filter. Does anyone know why this might be happening?

    Hi Erica,

    Have you referred: CS6 still not installed with creative cloud

    Kind regards

    Sheena

  • Questions about the reorganization of the rows in the table by drag-and - drop feature

    I am referring to the demo: 106. Drag-and-drop the reorganization of the rows of the table in aCorner of Code DF to implement my case.

    I am facing some problems:

    1. the view object (bound to the table) is read only and it is created directly by very complex SQL queries, without entity objects. When it is run the code: dragRow.removeAndRetain () in the method: DnDAction processDrop (DropEvent dropEvent), it throws the error so that a guest view object is read-only. I want to know if there is another way to delete the moved collection line?

     public DnDAction processDrop(DropEvent dropEvent) {
    ...       
           CollectionModel collectionModel = (CollectionModel) table.getValue();        
            JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) collectionModel.getWrappedData();
            
            //get access to the ADF iterator binding used by the table and the underlying RowSetIterator.
            //The RowSetIterator allows us to remove and re-instert the dragged row
            DCIteratorBinding departmentsIterator = treeBinding.getDCIteratorBinding();               
            RowSetIterator rsi = departmentsIterator.getRowSetIterator(); 
    
            int indexOfDropRow= rsi.getRangeIndexOf(dropRow);
           //get access to the oracle.jbo.Row instance represneting this table row
           Row dragRow = (ViewRowImpl)table.getRowData(draggedRowKey);
           //remove dragged row from collection so it can be added back
           dragRow.removeAndRetain();
           rsi.insertRowAtRangeIndex(indexOfDropRow, dragRow);
          ...
    }
    

    2. When you click on a button, I need to save the command results in the database using the command update # of each rank. Here it is the handler method for the event of the action (in MB) button.

    I want to use RowSetIterator table for encode it from all ranks and update the value # order of each rank.   I call a data control method to run sql update. is it ok? any suggestion?

        public void processSaveOrder(ActionEvent actionEvent) {
            CollectionModel collectionModel = (CollectionModel) mytable.getValue();        
            JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) collectionModel.getWrappedData();
            
            //get access to the ADF iterator binding used by the table and the underlying RowSetIterator.
            //The RowSetIterator allows us to remove and re-instert the dragged row
            DCIteratorBinding iterator = treeBinding.getDCIteratorBinding();               
            RowSetIterator rsi = iterator.getRowSetIterator();
            Row row =rsi.first();
            System.out.println(0+"="+ row);
            int i = 1;
            while(rsi.hasNext()){
                row = rsi.next();
                System.out.println(i+"="+ row.getKey());
                i++;
            }
    
        }
    

    A workaround solution was found:

    In ADF 12 c, it can be solved by changing Updatable "Always" in the details tab of each attributes to read-only view object without entity object.

  • Strange behavior of the cursor to the row in the table

    Hello.

    I use JD Studio Edition Version 11.1.1.5.0 on Weblogic 11.1.1.5

    I have page JSPX in taskflow bounded to view history records in the table.

    DB table is simply with a single primary key and number of columns.

    On the page, I show only little of them (Date, user, Rec.Number and State).

    When I open this dialog box with records that hold these documents

    ID Date user RecNumber State

    67

    02.01.07User111

    68

    02.01.07User122

    69

    02.01.07User131

    70

    02.01.07User142

    71

    02.01.07User151
    7202.01.07User162

    I see highlighted records with status = 1. Click on any record highlighting disappears and when I try to move the cursor down through the cursor of the keyboard (arrow keys) Stoops (pressing "down") until that record 3rd then skip (press 'down' key) 2nd record and repeat this. When I try to move the top slider to 5th/4th then folder and back loop.

    When I leave the body of the table and click outside the table then highlighting appears again.

    If I show only records State = 1 then all records are highlighted and the cursor jumps between 2nd and 5th record.

    ADF table is created simply by dragging and dropping of DataControl with RowSelection simple =, rowBandingInterval = 0, filterVisible = "true".

    I can find no reason for this kind of behavior.

    Please help me understand what can be the reason of this madness.

    Thanks in advance

    I check the original Version and compare it with the last good version.

    I found at the end

    This section is missing from the right version

    I add

    and everything is fine now.

    The same problem was in an another PK VO. missing base table.

  • ERROR: could not insert a value zero in the table. &lt; nom_de_colonne &gt;

    Hi all

    I am facing the problem as follows:

    I've had several columns in the table "transaction".
    the table consists of columns

    transaction_id (PK)
    username (FK)
    equipment (FK)

    The form is made up of 3 columns,
    I would like to have username automatically shown as a text that is displayed by mapping to app_user.

    However, the value is treated as a null value when I tried to insert in the transaction of the table.

    the error is as follows:

    ORA-01400: cannot insert NULL into ('ITEMS'. "OPERATION '." ("" USERNAME ")
    Cannot process the TRANSACTION table row.

    I post in this thread
    app_user
    but I'm not able to solve the problem too, please advice.
    It is very urgent for me.

    Thanks in advance.

    Hello

    If you don't want the user to be able to change it and you want according to the value on the current user name, edit the item and:

    1 set the type: display text (State record)

    2 assign the default value: APP_USER

    3. set the default value Type: PL/SQL Expression

    4 - Set the Source: always, replacement of value that exists in session state

    5 set the Source Type: database column

    6. set the value of the Source or the expression to: username

    Andy

  • identify the tables that are affected by a transaction

    Hi guys,.

    I am running version:

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE Production 11.2.0.3.0
    AMT for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production



    Is it possible to identify the SQL code or the tables involved in a transaction by looking at the transaction$ v?

    Just wrote a small application, but can't test it in my DB... Just check it...
    Basically CREATE all the views will provide some information.

    SELECT t.ses_addr,
           s.sid,
           p.object_id,
           D.OBJECT_NAME,s.command
      FROM v$transaction t,
           v$session s,
           V$locked_object p,
           dba_objects d
     WHERE     t.ses_addr = s.saddr
           AND p.session_id = s.sid
           AND d.object_id = p.object_id;
    

    The command column is a code displays what kind of operation is being currently... the explanation of the code can be mentioned in the documentation:

    http://docs.Oracle.com/CD/B19306_01/server.102/b14237/dynviews_2088.htm

    See you soon,.
    Manik.

  • EBS: The table / view po_vendors belongs to what schema in ebs 12.2.4

    Hello

    I want to use the view 'po_vendors' in one of my request

    Now I want to know what it is. is it po.po_vendors or 'apps.po_vendors '.

    I'm confused because I found po.po_vendors in some old request. I use oracle ebs 12.2.4

    Thank you.

    Hello

    The "po_vendors" was a table in the PO schema in Oracle EBS 11i.

    In R12, providers are stored in 'ap.ap_suppliers' instead.

    "po_vendors" is retained for backward compatibility as a point of view and it gets the data to ap_suppliers.

    Kind regards

    Bashar

  • Complete export dashboard in excel gives error generate document in the table view of subtotals

    Hi all

    We have dashboard with several tabs and you try to export the whole dashboard in excel.

    Excel file is generated with all tabs on the dashboard as the leaves, but few of these leaves are empty with error message of document generation in the first cell.

    After further analysis, we concluded that the cause is seen with subtotals on table. PivotTables with subtotals are generated correctly.

    Workaround obvious to re-create the table views in the articulation points is not possible due to a large number of reports.

    We run Oracle Business Intelligence Product Version 11.1.1.7.150120 (Build 150113.1200 64-bit)

    Any ideas or solutions to this problem would be appreciated.

    Thank you;

    Klaudio

    We just found guilty

    Lines per page to display in the table must be 999999999 max which is more than enough for our needs.

  • I'm opening table row in a popup with the help of change. If I opened a line to edit, and then if I cancel the popup and if I open some row of the table, then instead of the newly selected line diff, previously selected line becomes open question. Help, p

    @Code is:-

    I have a panelCollection which is having an ADFTable (VO) and < f: toolbar > < coomandToolbarbutton > IE change by clicking on modify the selected line of the tbal adf becomes open in edit mode in a popup. Buttong ActionListner change creation popup

    {} public void handleEdit (ActionEvent actionEvent)
    Add the code in the event here...

    Line selectedRow =
    (Row) ADFUtils.evaluateEL ("#{bindings.") BtEsAwardsSchemeSetupVO1Iterator.currentRow}");
    Line selectedRow =
    (Row) ADFUtils.evaluateEL ("#{bindings.") BtEsAwardsSchemeSetupVO1.currentRow}");

    Tips RichPopup.PopupHints = new RichPopup.PopupHints ();

    this.getAddEditpopup () .show (hints);
    }

    Pupup has two buttons for Submit and cancel.
    Click on Cancel button on the popup, it id hide. The question is, suppose that the table is to have 4 lines so if I first select third row and click on change that becomes open editing on a popUp, but if I click on the Cancel button and their selection a few rows of table (Say first line), the previously selected (3rd row) rank only becomes open again in popup instead of the newly selected row.
    Cacel code

    {} public void handleCancelAwards (ActionEvent actionEvent)

    Add the code in the event here...

    ADFUtils.invokeEL ("#{bindings.") Rollback.Execute}");

    this.getAddEditpopup (.cancel ()); [I also tried with hide and seek but not worked]

    }

    Thanks in advance and thanks for your time

    It may be a problem with the combination of: immediate = true, rollback, and af:popup.

    You can try adding af:resetActionListener to the Cancel button.

    BTW, your managed bean is in the package that start with uppercase ("Bean"). (if you should refactor this to "beans" (for example))

    Dario

  • CDC - J$ triggers in the Table, the view

    Hi friends,

    When we are implementing Change Data Capture, the back end what are the roles of logging table, table of the Subscriber, views and triggers?

    Can someone explain in detail?

    Thanks in advance.

    Hello

    Sure it's covered in another post here - have you tried the search?

    Triggers: Applied to the source table, write the PK columns on insert/update/delete in the Journal table.

    Leaf table: holds the pharmacokinetics of changes.

    Views: knuckles (external) the table of the Journal to return to the source table to complete the rest of the line, deletes only the PK is filled

    The Subscriber tables: here's the clever part - better if you take a look here, once you put in place: CDC framework suppors multiple subsribers to a Publisher - each Subscriber has its own "window" of the changes, he is interested, this is controlled by the journal of lock / extend window options in ODI. The tables of the Subscriber is the owner of the min / max numbers YVERT for this window of subscribers, the display of log data use in a join to show only the window of changes required for ODI to a given subscriber.

    Note: in the newspaper view data, you will find a record of change repeated for as many subscribers you have, this is normal.

    Good luck!

Maybe you are looking for