Select the year max and max date for a code

Hello

I need to extract max year and month max for one code particulare.

My table contains:

YEAR MONTH CODE

====   =====    ====

2014 6 X

2014 7 X

2013 5 Y

2013 6 Y


I need to extract:


2014 7 X

2013 6 Y


I don't like max(YEAR|| le mois), I want the column separated.


Thank you

Try this:

WITH test_data AS (
  SELECT 2014 AS yr, 6 AS mth, 'X' AS code FROM DUAL
  UNION ALL
  SELECT 2014 AS yr, 7 AS mth, 'X' AS code FROM DUAL
  UNION ALL
  SELECT 2013 AS yr, 5 AS mth, 'Y' AS code FROM DUAL
  UNION ALL
  SELECT 2013 AS yr, 6 AS mth, 'Y' AS code FROM DUAL
)
SELECT yr
     , MAX(mth) KEEP (DENSE_RANK FIRST ORDER BY 100*yr+mth DESC) AS mth
     , MAX(code) KEEP (DENSE_RANK FIRST ORDER BY 100*yr+mth DESC) AS code
FROM   test_data
GROUP BY yr
ORDER BY 1;

Obviously by storing your dates as the DATE, then ranked by who would be more elegant!

Tags: Database

Similar Questions

  • Select the year, current and future year

    Hello world
    I have the select statement where I want to put the current year and the following year like this: 2011-2012
    That's what I have so far, but I do not know how to bring the other party.
    I added a when-validate-point trigger and put the following inside:
    BEGIN
    SELECT (TO_CHAR (SYSDATE, 'YYYY') |) » -'|| TO_CHAR(SYSDATE,'YYYY+1')) IN: SCHOOL_YEAR
    FROM DUAL;
    END;

    Gives me an error on the second tank. Can someone help me on this please?

    Mayen something like this:

    SELECT EXTRACT(YEAR FROM sysdate), EXTRACT(YEAR FROM add_months(sysdate,12)) from dual
    

    François

  • My nail of the thumb in bridge always have evidence the adjustments I make to RAW files. Now, for the first time they have not. However when I select the images adjusted and open them in CS6 adjustments are there. I restarted the bridge and PS, and I rest

    My nail of the thumb in bridge always have evidence the adjustments I make to RAW files. Now, for the first time they have not. However when I select the images adjusted and open them in CS6 adjustments are there. I restarted bridge and PS, and I restarted the computer (Mac). Still the same problem.

    I thank assani, but it wasn't the answer. The problem was, I finally understood, that the "option for generation of quality and preview thumbnails" wasn't on "high quality" as it usually is. I have no idea how this happened as I never change this option.

    Thanks a lot for your help.

    Mitchel Gray

  • get the IOPS / s and flow rate for each card of vmhba

    Hi, I have seen a few difficulties for the IOPS / s and flow stat for esxi for each vmhba card get the average, max, min

    I can get some network like net.usage.average, net.received.average and net.transmitted.average parameters as the metric is consolidated for all the network card.

    Here is the part of the classic script I use

    $metrics = "net.received.average", "net.transmitted.average".

    Get-Stat - entity $esx - start $start - finishing $stop - MaxSamples 10000 - Intervalmin 30 - stat $metrics |

    Group-object - property {$_.} @entity.name} | %{

    $esxname = $_. Group [0]. @entity.name

    $hard = (get-VMhost-name $esxname) .extensiondata. Summary.Hardware

    $netreceived = $_. Group | where {$_.} MetricId - eq "net.received.average" - and $_. {Instance - eq ""} | Measure-object-property value - average - Maximum - Minimum

    $nettransmit = $_. Group | where {$_.} MetricId - eq "net.transmitted.average" - and $_. {Instance - eq ""} | Measure-object-property value - average - Maximum - Minimum

    and so now, but on the storage card, consolidated metrics do not exist...

    Thank you very much!

    Try something like this

    $esx = Get-VMHost MyEsx$stat = "storageAdapter.numberReadAveraged.average","storageAdapter.numberWriteAveraged.average"$start = (Get-Date).AddMinutes(-5)
    
    Get-Stat -Entity $esx -Stat $stat -Start $start |Group-Object -Property Instance,Timestamp | %{$_ |Select @{N="Timestamp";E={$_.Values[1]}},@{N="Instance";E={$_.Values[0]}},@{N="Read IOPS";E={$_.Group | where {$_.MetricId -eq "storageAdapter.numberReadAveraged.average"} | %{$_.Value/$_.IntervalSecs}}},@{N="Write IOPS";E={$_.Group | where {$_.MetricId -eq "storageAdapter.numberWriteAveraged.average"} | %{$_.Value/$_.IntervalSecs}}}}
    

    It uses more or less the same concept that I used in my post to get the OPS are / s maximum .

  • Select the emp with a maximum salary for each hr.emp manager_id

    Hello
    Can someone help me to do this without doing any partitioning or analytical f:

    Select the emp with a maximum salary for each hr.emp manager_id.

    HR. EMPLOYEES Table Description: =.
    EMPLOYEE_ID
    FIRST NAME
    LAST_NAME
    HIRE_DATE
    JOB_ID
    SALARY
    COMMISSION_PCT
    MANAGER_ID
    DEPARTMENT_ID

    TX, all the guys
    Mario

    Hi, Mario,.

    Here's one way:

    SELECT       *
    FROM       hr.employees
    WHERE       (manager_id, salary) IN (
                                          SELECT    manager_id
                              ,               MAX (salary)
                              FROM     hr.employees
                              GROUP BY  manager_id
                                   )
    ;
    

    mario17 wrote: Hi,
    Can someone help me to do this without doing any partitioning or analytical f:

    Do you mean analytical functions?
    Why you don't want to use the analytical functions? Analytical functions, permitting the simpler, more robust and more effective to achieve these results, wouldn't you want that?

  • I have a charger for the iPhone I'll be able to go to the Apple Store and trade it for a new?

    I have a charger for the iPhone I'll be able to go to the Apple Store and trade it for a new?

    A1yvng wrote:

    I have a charger for the iPhone I'll be able to go to the Apple Store and rare it for another?

    I'm sorry, but that 'rare' mean in this sentence? If you are having problems with a charger and the phone, he came up with that is still under warranty, the unit would be under warranty. It will have to be reviewed by Apple, they make determinations. If you have purchased separately the charger, then it must be aged less than 1 year, and the review itself would apply. I hope that's what you're referring to.

  • Printer all in one HP3520 - how to select the wireless network and enter the WEP key?

    According to print my wireless network is detected.

    How to connect the! @# % printer $ fo the wireless network and enter the WEP key?

    Instructions on the HP site tell me to selet NETWORK on the printer control panel.  Well, there's a way to select the NETWORK from the control panel.  It is not an option for him.

    I downnloaded and installed the latest drivers.

    I have restored the default settings.

    How to select the wireless network and enter the WEP key?

    All of HP's instructions seem to be for a newer printer with a touchscreen.

    I want that the printer is connected to my main computer via the USB port.  I want to be able to print wireless phones and tablets.

    My 3520 is not a 'touch Screen' and it has wifi.

    However, the following work:

    Try to open the HP Deskjet 3520 icon, open the utilities tab, click on convert USB wireless, by following the steps on the screen.

    This leads me to believe that ONLY the wireless doesn't work.  I know now that the part of the sentence "Convert USB to wireless connection" is supposed to mean "works like USB and wireless.

    Thank you for your help

  • I plan to upgrade my OS to El Capitan.  What are the processor speed and memory required for the operating system works well?

    I plan to upgrade my OS to El Capitan.  What are the processor speed and memory required for the operating system works well?

    I use a processor 2.3 GHz Intel Core i5 with DDR3 4 GB 1333 MHz memory.

    My last similar attempt on another machine resulted in a very slow computer.

    Thanks, Ron

    Apple says the following:

    General requirements

    • OS X 10.6.8 or later version
    • 2 GB memory
    • 8.8 GB of available storage

    For best performance, I would say not less 4 GB and preferably 8 GB or more.

    Your i5 is well able to support properly.

    http://www.Apple.com/OSX/how-to-upgrade/#Hardware Configuration

  • Is it possible to access the USB ports and a slot for card SDX?

    Is it possible to access the USB ports and a slot for SDX card at the back of the iMac?

    Rotate the iMac autour to see ports.

  • Y at - it a utility to monitor the speed, temperature and cpu/gpu for desektop m9200T fan?

    My desktop running Win7 Home Premium m9200T computer crashes often.  It seems to be associated with temperature.

    I tried SpeedFan, but my computer crashed whenever I ran it.  The SpeedFan 20 window scroll a few lines of text that the computer crashed.  Y at - it a utility to monitor the speed, temperature and cpu/gpu for desektop m9200T fan?

    PC Wizzard works well on my computer.

    Thanks Big_dave.

  • "When I click on the SHIFT key and 2 keys for Word marks, I get and when I click shift and ' key I get"

    When I click on the SHIFT key and 2 keys for Word marks, I get and when I click shift and ' key I get "... The keys have changed places?

    Original title: keyboard

    Go to the Panel control, region, language, keyboards & languages, change keyboards, tab bar of language and, if you regularly change language settings, make the hidden language bar. I think you have touched a keyboard shortcut that has hired it & changed the region / language settings and therefore caused this problem.

    Then go to control panel, region, language, keyboards & languages, change keyboards, advanced settings tab key where you can see the key sequence of shortened which probably you entered this problem by chance. You will also see the sequence of modifier keys that you want to change by clicking on the button sequence of modifier keys and by setting the input language switch & switch keyboard to not [when I changed them, I had to define not entitled for the switch input language and accept change, and then return to the dialog box to set no affect for the keyboard switch setting].

  • Select the crop tool, and then select a ratio (based on the name of the file)

    I have a lot of files that when I their culture that they need a specific report. Currently, they are stored in the tool.

    I wish I could make a shortcut so that it selects the crop tool and the report to the file name. I can understand the file name information.

    i.e. Fr10 = a 2:3 Ratio

    or

    20 = 3:4

    There is no need to crop the image simply select the tool.

    I found this to select the tool

    The beginning is the same.

    if (app.documents.length > 0) {
        var myDocument = activeDocument;
        var fileNameNoExtension = myDocument.name;
        
      fileNameNoExtension = fileNameNoExtension.split( "." );
        
      if ( fileNameNoExtension.length > 1 ) {
          fileNameNoExtension.length--;
        }
    
        fileNameNoExtension = fileNameNoExtension.join(".");
        
        var BrandString = fileNameNoExtension.substr(0,4);
      
      }
    if (/^(FR10|WA35)$/.exec(BrandString)){
        var the_x_Ratio =2
        var the_y_Ratio =3
        }
    

    2016, use it at your own risk.

    #target photoshop

    If (app.documents.length > 0) {}

    myDocument var = app.activeDocument;

    var originalRulerUnits = app.preferences.rulerUnits;

    app.preferences.rulerUnits = Units.PIXELS;

    var width = myDocument.width;

    var height = myDocument.height;

    var rel = 1;

    If (myDocument.name.indexOf ("AB10")! = - 1) {var rel = 0,666};

    If (myDocument.name.indexOf ("CD10")! = - 1) {var rel = 0.75};

    If (myDocument.name.indexOf ("EF10")! = - 1) {var rel = 0.8};

    If (myDocument.name.indexOf ("CH10")! = - 1) {var rel = 0,833};

    try {}

    // =======================================================

    var idCrop = charIDToTypeID ('Crop');

    var desc3 = new ActionDescriptor();

    idT var = charIDToTypeID ("T");

    var desc4 = new ActionDescriptor();

    var idTop = charIDToTypeID ('Top');

    var idPxl = charIDToTypeID ("#Pxl");

    Desc4.putUnitDouble (idTop, idPxl, 0);

    var idLeft = charIDToTypeID ("Left");

    var idPxl = charIDToTypeID ("#Pxl");

    Desc4.putUnitDouble (idLeft, idPxl, (width - height * rel) / 2);

    var idBtom = charIDToTypeID ("Btom");

    var idPxl = charIDToTypeID ("#Pxl");

    Desc4.putUnitDouble (idBtom, idPxl, height);

    var idRght = charIDToTypeID ('Rght');

    var idPxl = charIDToTypeID ("#Pxl");

    Desc4.putUnitDouble (idRght, idPxl, (width - height * rel) / 2 + height * rel);

    var idRctn = charIDToTypeID ("Rctn");

    Desc3.putObject (idRctn, idT, desc4);

    var idAngl = charIDToTypeID ("Marko");

    Bryan var = charIDToTypeID ("#Ang");

    Desc3.putUnitDouble (idAngl, Bryan, 0.000000);

    var idDlt = charIDToTypeID ("Dlt");

    Desc3.putBoolean (idDlt, false);

    var idcropAspectRatioModeKey = stringIDToTypeID ("cropAspectRatioModeKey");

    var idcropAspectRatioModeClass = stringIDToTypeID ("cropAspectRatioModeClass");

    var idpureAspectRatio = stringIDToTypeID ("pureAspectRatio");

    Desc3.putEnumerated (idcropAspectRatioModeKey, idcropAspectRatioModeClass, idpureAspectRatio);

    var idCnsP = charIDToTypeID ("CnsP");

    Desc3.putBoolean (idCnsP, true);

    executeAction (idCrop, desc3, DialogModes.ALL);

    } catch (e) {};

    //

    app.preferences.rulerUnits = originalRulerUnits;

    };

    Edit: Using the indexOf can be problematic and if-clauses are inelegant, then a switch clause would be probably better.

  • Where can I get the certificate of tax residence to tax the year 2015 and 2016 Adobe?

    Where can I get the certificate of tax residence to tax the year 2015 and 2016 Adobe?

    Hello

    Please contact support Adobe Chat or by phone to get the certificate of tax residence

    Contact the customer service

    Make sure you are signed in with your Adobe while accessing the above link ID

  • How to add the chapter name and page not for reference

    Hello

    How to add the chapter name and page not for reference in indesign CS6.

    Thank you

    Please try variable notion of text

  • I'm not able to select the cloud, polygons and drawing markup tools lines connected to this end.

    I recently installed Adobe Pro XI. I can't select the cloud, polygons and lines connected markup drawing tools. I can see them, but they are greyed out so I am not able to choose them.

    I am running Windows 7 64 bit on an Asus ZenBook laptop.

    Any help would be really appreciated.

    Kind regards

    KF Panda

    This touchscreen laptop is capable?

    If this is not the case, check if you have the Touch preference in Adobe Acrobat active XI.  If you, then turn off.

Maybe you are looking for

  • New IPhone SE does not sync for Macbook Pro

    My new that i Phone SE will not aync to my Macbook Pro.  The States of error message that my phone can't synchronize on i tunes because it requires a new version of custom i.  Currently, I have version 12.2.2 and tried to update, but the Mac says tha

  • Life time before the computor makes me log in again?

    How to set the time until the computor makes me log in again?

  • How to print black and white color image/doc/pdf levels?

    Hello I use the Photosmart C4683 and want to print documents in black and white / black white even if the file itself is colored in order to save on the color ink cartridge and more do not require the prints in color. I have searched the respective p

  • How to bring back the good old paint?

    The new paint is so bad. I use Paint to make pictures in digital images and the new paint makes it virtually impossible to do. It's just absolutely horrible and I have more use for it because it's so bad. Windows 7 makes me wish I had a mac.

  • change the HD, what OS?

    I want to change my HD to my computer Dell laptop XPS 1647. I want to install a new HD SSD inside, but I can't find my OS Windows7 how came with this laptop. What do I do now? Geetings Logist T.