Remove all lines but more recent of each

Hello

I have a table with about 3.6 million lines and came up with an idea of how to improve the speed of a query. Basically, my idea was to create a query that took (finally to enter into a historic table) all records associated with a particular area, except for the 2 last because they are the only ones used. For example:


SPORT |    DRIVE |    DATE
========================
RONALDO FOOTBALL 8 JULY 09
RONALDO FOOTBALL 11 JUNE 09
RONALDO FOOTBALL 22 MARCH 09
FEDOR MMA 10-SEP-09
FEDOR MMA AUGUST 15 09
FEDOR MMA 11 AUGUST 09

The idea is that the last recordings of ronaldo & fedor would be removed somehow... All the things I've tried so far have been a disaster =)
Thanks for any help.

Mike

The first step would be to create a select that adds a new column to your table that contains some sort of grade.
Something like this:

select sport,
    player,
    date,
    dense_rank () over (partition by sport, player order by date desc) rank,
    row_number() over (partition by sport, player order by date desc) nr
from yourbigtable

Rest can be support on this. The difference between the two columns is that grade will give the same number for identical dates, while row_number() will give a new number for each line by group.

Tags: Database

Similar Questions

  • htmlText remove all line breaks

    In my program, a user can enter any type of text using a RichTextEditor. The entered text has all its illegal xml characters replaced (< with & lt ;) etc.) This string is placed in an xml document. A component is custom, then receives the xml document, converts the html code in its original form and the applicable as the htmlText of a property control of text. This used to work properly. I need string conversions because there are some "metaStrings" which is not replaced according to certain criteria... which is the string {$DATE} would get replaced by the effective date when loading at a later date. As I said, used to work, and I had no problem display of text exactly as the user who created it. Now, for some reason, when I set the htmlText property, all line breaks are removed, of any type. < here > < p > < / p > < /li > < li > for fleas. Remains of formatting, has increased the font size, color, etc., but there is no line breaks.

    I have my chiseled loading code and the following output:

    public static void loadHtmlText(textControl:Text,_textData:XML,_replaceMeta:Boolean_=_false):void
    {
    trace ("loading text html in a text component, loading", textData);
    var html:String = textData.Html.toString ();
    trace ("after parsing a string", html);
    If (replaceMeta)
    {
    trace ('replacing');
    HTML = html.replace(/\{\$DATE\}/,textData.Date);
    Add sequences additional meta here for replacement
    }
    trace ("after the replacement", html);
    textControl.htmlText = html;


    textControl.validateNow (); force a commit
    trace ("value that was set', textControl.htmlText");
    }

    and the following output:

    text html in a text component loading, loading
    < data >
    < html > & lt; TEXTFORMAT LEADING = "2" & gt; & lt; P ALIGN = "LEFT" & gt; & lt; FONT FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = "0" KERNING "0" = & gt; Line 1 & lt; / FONT & gt; & lt; /P & gt; & lt; / TEXTFORMAT & gt; & lt; TEXTFORMAT LEADING = "2" & gt; & lt; P ALIGN = "LEFT" & gt; & lt; FONT FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = "0" KERNING "0" = & gt; Line 2 & lt; / FONT & gt; & lt; /P & gt; & lt; / TEXTFORMAT & gt; & lt; TEXTFORMAT LEADING = "2" & gt; & lt; P ALIGN = "LEFT" & gt; & lt; FONT FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = "0" KERNING "0" = & gt; Line 3 & lt; / FONT & gt; & lt; /P & gt; & lt; / TEXTFORMAT & gt; < / Html >
    NotSet < date > < / Date >
    < / data >

    after parsing a string
    < TEXTFORMAT LEADING '2' = > < P ALIGN = "LEFT" > < FONT FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = '0' KERNING '0' = > line 1 < / POLICE > < /P > < / TEXTFORMAT > < TEXTFORMAT LEADING '2' = > < P ALIGN = "LEFT" > < FONT FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = '0' KERNING '0' = > line 2 < / FONTS > < /P > < / TEXTFORMAT > < TEXTFORMAT LEADING = "2" > < P ALIGN = "LEFT" > < FONTS FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = '0' KERNING '0' = > line 3 < / POLICE > < /P > < / TEXTFORMAT >

    After replacing
    < TEXTFORMAT LEADING '2' = > < P ALIGN = "LEFT" > < FONT FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = '0' KERNING '0' = > line 1 < / POLICE > < /P > < / TEXTFORMAT > < TEXTFORMAT LEADING '2' = > < P ALIGN = "LEFT" > < FONT FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = '0' KERNING '0' = > line 2 < / FONTS > < /P > < / TEXTFORMAT > < TEXTFORMAT LEADING = "2" > < P ALIGN = "LEFT" > < FONTS FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = '0' KERNING '0' = > line 3 < / POLICE > < /P > < / TEXTFORMAT >
    set < TEXTFORMAT LEADING = "2" > < P ALIGN = "LEFT" > < FONT FACE = "listFont" SIZE = "10" COLOR = "#0B333C" LETTERSPACING = '0' KERNING '0' = > line 1Line, 2Line 3 < / POLICE > < /P > < / TEXTFORMAT >



    Uh, oops, all the strings wordwrapped, makes it impossible to read. There were three blocks < P > < / p > adopted in
    each of them said line 1 line 2 and line 3, respectively, and each of them must be on its own line.

    After forcing the validation of the text control after setting this string, it has that one tag < P > < / p > with all the text inside... 2Line 1Line line 3.


    Any ideas?

    It worked before, I did was move the parameter text in its own function, insead of a function called by the method of my custom component's data provider.

    Thanks for the help.

    Wow, almost three months later, when my work schedule allows me actually to take over this problem, and I have the solution :-). It turns out, I don't know why, or if same Adobe knows about the bug, but if you have fonts using style sheets for all controls on your application, that is, I have a style statement request where I placed the police then redering text html of the text control is bug, usually just remove all line breaks. Why, I have no idea, he is simply. However, the same bug does not occur in the TextArea component. Still, I don't know why, seems silly to me, but as the solution to this problem, simply create a component TextArea, backgroundAlpha styles set to 0, its borderStyle to 'none', set the editable to false and boom, you have a component of scrolling text, which doesn't render the text html incorrectly.

  • Remove all lines and insert them into Oracle can make performance worse?

    I m working in a project that I need to make a batch update regularly (every 4 months) of excel files. These files have doesn´t excellent key in their ranks.

    The development of a code that deletes all lines and inserts the entire base again is easier than one who checks in all the ranks of its primary key and if necessary update. (sometimes may be a key to 5 columns).

    My question is: if I delete all the rows in the tables of the insert it again, it will cause tablespace fragmentation and in a future loss of performance?

    Is there a way to avoid this?

    Thanks in advance

    Alexander

    This response helped me a lot.

    Thank you all

    Remove all lines and insert them into Oracle can make performance worse? -Stack overflow

  • FTP Dreamweaver CC2015 removes all line breaks in the php files. How can I fix this problem?

    When I upload a php file. The ftp transfer removes all line breaks and creates a continuous line of unique text. I need to download the code with all the line breaks in the original php file correctly.

    I found the problem.

    FTP of Dreamweaver CC 2015 program is not compatible with Yosemite 10.10.5 on all ftp servers.

    The new version of FileZilla (v 3.14.0) is also not consistent.

    Fetch 5.7.5 is fully compatible with Yosemite. With Fetch, I can download the files without any problems successfully.

    In their update, Fetch mentioned that the problem is not with all servers.

    I host on Unix servers with HostGator AMD Opteron processors running on an OS GNU/Linux 64 - bit.

    If you run Yosemite and ftp of Dreamweaver is ruin your line breaks, then use Fetch until Adobe can fix their problem.

  • Remove all applications, but not the settings

    I would like to delete applications off iPad to my kids, but keep the settings. As a result of bad choices, they lost the use of the device for a month with the exception of a few applications of education. Because the device has more than 200 applications, I'm trying to understand if there is a relatively easy way to remove all applications (I can reload education ones), but all the settings I have for the device. I backed up the iPad and thought that I could restore all applications after their months of purgatory. Any ideas or suggestions on how to do it quickly?

    No, there is not. Unless you're willing to wipe both parameters, applications will have to be deleted individually. However, with 200 apps, it could be easier to wipe and reintroduce the parameters.

  • Remove all lines except 10 random lines

    Hello

    How to remove all the lines in the JOBS table except 10 lines at random?

    Someone asked him before (not here...): http://stackoverflow.com/questions/10820105/t-sql-delete-except-top-1

    but I didn't get the answer, and I don't think it will work in PL/SQL.

    If the answer to StackOverflow's works in PL/SQL, I will be happy if someone explains me with a better example.

    If the answer to StackOverflow does'nt work in PL/SQL, I will be happy if somebody give me an example.

    Thank you!

    Try this

    delete from jobs where rowid not in (select rowid from jobs where rownum <= 10)
    
  • Remove all line breaks

    Hello

    When you paste Acrobat PDF files into InDesign, I often have a ton of extra newlines, I don't want to. Someone at - it a script to remove all the jumps of line in a block of text?

    Why you want to script?

    Just go find grep select request: multiple return unique back, and then click all change.

    Please make sure that you have selected the Option to search: story if you want to change the selected block of text.

    Shonky

  • How can I remove old history but keep recent history?

    There is an easy way to clear recent history in Firefox 3.6.4. But even if I set Firefox to remember the sites visited during "at least" 30 days, he remembers them for months and even years. I would like to have, automatically, if possible, purge history older than some set interval. Lacking, I would like a way to manually remove history prior to a date. Is there a way to do this? I search the forums and the Add-ons and came empty.

    You can watch these prefs the subject: config page.
    http://KB.mozillazine.org/browser.history_expire_days (180) (also affects saved form data)
    http://KB.mozillazine.org/browser.history_expire_days_min (90)

    To open the topic: config page, type Subject: config in the address bar (address) and press the Enter key, as you type the url of a Web site to open a Web site.
    If you see a warning then you can confirm that you want to access this page.
    .....
    These prefs will be removed in future versions of Firefox 4.0 and replaced with a pref places.history.enabled unique to remember the story or not.

  • Used the shower pc to arasoft which seems to have removed all bookmarks but now impossible to restore the back upward and impossible to import the saved html file. What else can I do to get the Favorites? Automatic bookmarking also seems to have been disa

    Have removed shower PC system. When I try to bookmark a page with bookmarks bar or star to address I get a details page to fill. Why has it been re together?

    What happens has a new profile?

    http://KB.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows

  • Button to remove all empty lines

    I am trying to create an interactive form that has a button that adds lines for the user to enter questions and another to add follow-ups to the authorities. There are 3 different sets of these. However, we do not want to add a button to remove all lines, in order to allow the accidental deletion of data already entered.  I would like to create a button that deletes all empty lines, including all subforms.  Either that, or to save the document, would be deleted all empty lines - depending on what would be easier. Help, please!  It seems that this will be a complicated task and I'm not well versed in LiveCycle to figure this on my own.

    Thank you!

    In the object > range of liaison. I've included a screenshot on the forum.

    Niall

  • Is DataBlDel() the best way to remove channel lines?

    Hello

    I try to delete specific lines in a block of channels and find that DataBlDel() is extremely slow. Of course, my channels is fairly long (~ 36e6 lines), but I find that it takes hours to remove a handful of lines. Is there a better way to do it?

    The code I use is listed here:

    Option Explicit

    I have Sun

    I have = 1

    <=>

    < 0="">
    Call DataBlDel("[]/Time",i,1)
    Call DataBlDel ("[]" / Time Delta ", i, 1")
    Call DataBlDel ("[] / Force load Pin (PST_002_FCE)", i, 1 ")
    On the other
    i = i + 1
    End If

    Wend

    Everything is very appreciated, advice

    PorridgeMan.

    Hi PorridgeMan,

    This task can be done loads faster.  First, the DataBlDel() command is working on multiple channels and multiple lines at once, so you call it many more times to you.  If the time of<0 rows="" are="" contiguous,="" the="" ideal="" approach="" would="" be="" to="" use="" the="" find()="" function="" to="" get="" the="" first="" row="" where="" time="">= 0 and use exactly a call DataBlDel() to remove all lines not valid 3 channels.  If the time<0 rows="" are="" not="" contiguous,="" then="" i'd="" recommend="" using="" the="" calculator="" approach,="" like="">

    L1 = NOC ("specifying")
    L2 = ONC ("/ time Delta")
    L3 = ONC ("/ Force charge Pin (PST_002_FCE)" ")
    IF L1 0 > AND L2 > 0 AND L3 > 0 tHEN
    Call FormulaCalc ("Ch (L3): = Ch (L3) + NoValue * (Ch (L1)")<>
    Call FormulaCalc ("Ch (L2): = Ch (L2) + NoValue * (Ch (L1)")<>
    Call FormulaCalc ("Ch (L1): = Ch (L1) + NoValue * (Ch (L1)")<>
    Call ChnNoVHandle (L1, L2 & "," & L3, "Delete", "XY", 1, 0)
    END IF

    Brad Turpin

    Tiara Product Support Engineer
    National Instruments

  • Remove the line from the Excel report when generating reports

    Hi all

    I try to delete whole lines of the report excel during the generation of the report in excel, but I'm not able to do this. Here I am attaching an excel template, in that I want to delete line no 3 to 5 How can I do this. I'm using LabVIEW 8.6 Report Generation Toolkit for Microsoft Office 1.1.3

    Thanks and greetings...

    If there is no function to generate report for simple operations like this, then use the palette of VBA macros to run this code snippet:

    'remove all lines between two rows inclusive '.
    Void DeleteRows (intTopRow As String, intLastRow As Integer)
    Range (cells (intTopRow, 1), (intLastRow, 1)). EntireRow.Delete xlShiftUp
    End Sub

    Import Excel module allows to load the .bas file then run Excel Macro with parameters 3 and 5.  Check your security settings if you get an error in the macro.

  • MERGE statement - delete all lines?

    Hi all

    I am using Oracle 11 g and in my application, I need to update several existing records in a table in the Production environment. For this, I wrote a SQL logic using the "MERGE INTO" statement.

    Here's the SQL logic that I used.

    merge into the tar of the target

    a_l'_aide_de)

    Select

    EC.prim_id,

    CSM.Cptr,

    CSM.prm,

    CSM.scnd,

    CSM. PTXT,

    CSM.entn,

    CSM. ENPR,

    CSM.sevr

    t2 t1 ec cat inner join

    on ec.x = cat.y

    inner join s t3

    on ec.p = q.a.

    inner join t3 b

    on ec.m = b.n

    inner join t4 csm

    on)

    (lower (replace (cat.xn, b.sname |))) ((('-', ")) = lower (csm.xn))

    and (below (replace (s.yn, b.sname |))) ((('-', ")) = lower (csm.yn))

    and (lower (b.rn) = lower (csm.rn))

    )

    where ec.cptr is null

    and ec.prm is null

    and ec.scnd is null

    and ec.ptxt is null

    and ec.stxt is null

    and ec.entn is null

    and ec.enpr is null

    and ec.sevr is null

    ) CBC

    on)

    SRC.prim_id = tar.prim_id

    )

    When matched then update

    Set tar.cptr = src.cptr,

    tar.PRM = src.prm,

    tar.scnd = src.scnd,

    tar. PTXT = src.plcy_txt,

    tar. MID = "offline."

    tar.entn = src.entn,

    tar. ENPR = src.enpr,

    tar.sevr = src.sevr

    I doubt here, that is, if the condition WE in education MERGE gets failed then is it insert/delete all records in/to from the target table. But I think that it won't happen because I'm not specify the statement as 'WHEN DO NOT MATCHED THEN' right? Or default oracle will insert/remove all lines if the condition does not. ???

    Your help is very appreciated.

    Thanks in advance

    If your question is addressed, then close this thread.

  • Producer of Folio (webbrowser): more recent Folios have no thumbnails

    I noticed that the last build Folios do not show a thumbnail in the thumbnail view in my browser. Older folios are yet. If an add-in some books older Folios at the latest (like ads) they maintain thumnails but more recent articles simply do not.

    On my iPad fine however when making a table of contents discovers, the thumbnail view show correctly.

    Bug, problem known, user error?

    Are the new PDF sheets?

  • Option group a radio for all lines

    Hello developers,
    I then how questioning:
    On a presentation of tabular, to have a radio with a single option validation of Y for all lines.
    similar with option simple checkbox for all lines, but a single row it will be checked and others will be automatically disabled.
    If you know of similar examples, I'd appreciate if you let me know.
    Thank you.

    Hello

    Take a look on: Re: creating a Yes/No radiogroup... If selected then YES, another STEP in the table

    It's: http://apex.oracle.com/pls/apex/f?p=55041:18

    It is a normal report, but you may be able to adapt to it.

    Andy

Maybe you are looking for

  • How can I restore Favorites after migration to the cloud?

    This weekend, we migrated our computer system in the cloud. I was under the assumption that we were only migrate our email to the cloud. However, when I got to the office yesterday, I have Firefox was longer on my computer and subsequently were my fa

  • Toshiba 32L3433DG DLNA setup - how to navigate the shared files

    I activated in multimedia sharing options, I put media player on server base sides... but please tell me... where I have to go or do on my TV to browse folders shared network (in this case movies)? It's a big mystery I see

  • NB200-002: unable to use 2 GB of RAM!

    I have a NB200-002 (PLL20C) and can't seem to get my system to recognize any more than 1 GB RAM stick. The Toshiba Canada plug, it is said that the maximum RAM for this netbook is 1 GB, but that I don't understand, is that it seems that all the other

  • Impossible to restart the iphone 6 after the white screen

    Screen went blank (White) disabled through holding "home" button and the Start button / stop together, phone expected to restart, but it didn't. attached to load but once again nothing... any ideas would be greatly received.

  • Windows SBS 2003 Cal

    is it possible to tell which type of CAL are installed on a SBS 2003 Server (by user or device)?