Generate rankings based on points per division

Writing a database application that will be used in a series of races, where rankings are based on points per division.

I have data as follows:

division_id, sailor_id, points


I want to the output of a SQL statement

where the classification is based on points by division.

That is to say.

grade, sailor_id, division_id, points
1, 12, 1, 1
2, 13, 1, 6
1, 3, 14, 10
1, 2, 18, 2
2, 2, 10, 5
9, 22, 2, 3
4, 2, 23: 12
1, 3, 8, 1
2, 3, 56, 4

Based on your output:

SQL> WITH sample_data AS (SELECT 1 sailor_id,12 div_id, 1 pts FROM dual UNION ALL
  2                       SELECT 1 sailor_id,13 div_id, 6 pts FROM dual UNION ALL
  3                       SELECT 1 sailor_id,14 div_id, 10 pts FROM dual UNION ALL
  4                       SELECT 2 sailor_id,18 div_id, 2 pts FROM dual UNION ALL
  5                       SELECT 2 sailor_id,10 div_id, 5 pts FROM dual UNION ALL
  6                       SELECT 2 sailor_id,22 div_id, 9 pts FROM dual UNION ALL
  7                       SELECT 2 sailor_id,23 div_id, 12 pts FROM dual UNION ALL
  8                       SELECT 3 sailor_id,8 div_id, 1 pts FROM dual UNION ALL
  9                       SELECT 3 sailor_id,56 div_id, 4 pts FROM dual
 10                       )
 11  --End of sample data creation
 12  -- Start of main query. You can use it from here.
 13  SELECT RANK() OVER (PARTITION BY sailor_id ORDER BY pts ) rank
 14         ,sailor_id,div_id,pts
 15  FROM sample_data;

      RANK  SAILOR_ID     DIV_ID        PTS
---------- ---------- ---------- ----------
         1          1         12          1
         2          1         13          6
         3          1         14         10
         1          2         18          2
         2          2         10          5
         3          2         22          9
         4          2         23         12
         1          3          8          1
         2          3         56          4

9 rows selected.

SQL> 

Tags: Database

Similar Questions

  • What is an effective way to way logarithmic bin data with a constant number of points per decade?

    Hi all

    I would like to clean a logarithmic field of PSD in binning and averaging so that I have a constant number of points per decade (say 10, just for the sake of argument). Generally, means simpler and cleaner, I can think about getting this is research in the table entering all points between the frequencies A and B, with an average of these points and assigning a frequency (A + B) / 2 of the new average bin. However, I cannot find how to access frequency information, I need to achieve this. To be more clear, I can imagine if I had two tables, one who holds the frequencies calculated from my stream of incoming data, and the other which held and the amplitude of each corresponding frequency, that I might look for clues in the frequency table with values between A and B, then the average of the values in the table of amplitude which lie between the indices back put them in a new table with a new array of corresponding frequency. The process is a little more general that just on average every ten points, to say, as the number of points per decade continues to grow. My main obstacle at the moment, however, is that the amplitudes of the voltage are a set of values that receive through the operation of PSD, while the part of the frequency of the wave seems to be a DBL continues single-valued. I hope I've explained that well enough for someone to shed some light on my problem. Also, if anyone has a suggestion for a better way to approach the problem please let me know - there must be a pretty simple answer there, but it's deceiving me right now. Thanks in advance for the help.

    -Alex

    Hello

    If I get you right. you have:

    a table with the frequencies

    a table with the corresponding values of amplitude

    Then you want to merge parts of the data by averaging on the specific frequency ranges. I think that there is no VI 1 solution, you will need to write this on your own ():

    I start to get the min/max of frequencies and then interpolate a scale from your needs (like logarythmic) mounting with the quantity of bins you want. This should be an array again.

    Next step is to browse the frequency table, check (the first and) the last value in the location wanted (stop the loop, return the index). This should end up with an array of index. [I guess that's where you can save some computation time most by smart]

    Finally, use these indices to browse the amplitude values and make your average. Should return an array of the length of your array of locations.

    Ground in color fantasies and enjoy.

    Just what you intend to do?

  • Bouba Analyzer: How to control the number of points per decade?

    Total newbie here. I can't control the number of points per decade in the Bode VI. It's always 5 points per decade.

    Don't know even how to get the Version of Elvis #, but it is at a minimum 4.1, because Elvis installer will install 4.1 (said the current version is most recent). Running Windows XP.

    How can I get Elvis to respond to my request for more points per decade?

    Mike

    Hi Mike,.

    If you are still curious about what drivers you have installed, you can view by using the Measurement & Automation Explorer (start"all programs" National Instruments"Measurement & Automation Explorer).  "Once their, go to my system" software and you'll find NI ELVISmx and its version.

    This behavior you're seeing is a known, class problem under Corrective Action Request (CAR) #373017.  For now, the number of points per decade will remain at 5.  Please wait for the next update of NOR-ELVISmx to see if this problem is fixed.

    See you soon,.

  • Generate reports based on two conditions

    Dear all,
    I generate reports based on satisfactory conditions in two columns in a table.

    For example.
    I have a table test1 with columns A, B, C, D, E
    Now, I want to create reports based on the research of two columns A and b. What is the preferred method to do?

    Thanks in advance.

    What is the preferred method to do?

    Write the appropriate query:

    select a,b,c,d,e
    from test1
    where a = 
    and b = 
    

    In reports, the State may be a user input parameter:

    select a,b,c,d,e
    from test1
    where a = :parameter1
    and b = :parameter2
    
  • CS_SRS. WKTEXT generated value is being generated by commas instead points

    I was able to add a coordinate system: ETRS89 / Portugal TM06

    but the CS_SRS. WKTEXT generated value is being generated by commas instead points.

    is generated as:
    PROJCS ["" ETRS89 / Portugal TM06 ", GEOGCS ["ETRS89", REFERENCE ['European terrestrial reference (EPSG ID 6258) 1989 system', SPHEROID ["GRS 1980 (EPSG ID 7019)"6378137, 298,257222101]], PRIMEM ["Greenwich", 0.000000], UNIT ['decimal degrees', 0.01745329251994328]], PROJECTION [" ETRS89 PT-TM06 "], PARAMETER ['Latitude_Of_Origin', 39,6682583333333], ['Central_Meridian', - 8,13310833333333], PARAMETER ["Scale_Factor", 1], PARAMETER ["False_Easting", 0], ["False_Northing", 0], UNIT ["meter", 1]"]


    but should be like:
    PROJCS ["' ETRS89 / Portugal TM06", GEOGCS ["ETRS89", REFERENCE ["European terrestrial reference 1989 system (EPSG ID 6258)", SPHEROID ["GRS 1980 (EPSG ID 7019)" 6378137, 298.257222101]], PRIMEM ["Greenwich", 0.000000], UNIT ['decimal degrees', 0.01745329251994328]], PROJECTION ["ETRS89 PT-TM06"], PARAMETER ['Latitude_Of_Origin', 39.6682583333333], PARAMETER ['Central_Meridian',-8.13310833333333], ["Scale_Factor", 1], PARAMETER ["False_Easting", 0], ["False_Northing", 0], UNIT ["meter", 1] "]

    and the SDO_CS. VALIDATE_WKT gives FALSE (170).
    I could disable the trigger CS_SRS and update the value in the hand, but is it the right way?

    Hello Rui,

    to disable triggers, according to me, is not a good solution. You must solve the problem for the insert statement. Please have look more closely at the NLS settings during your session when you do the insert. I had good experiences to set the NLS parameter to the American environment. You should be able to influence the outcome of integration by setting the nls_numeric_characters ',' (set NLS_NUMERIC_CHARACTERS = ','.) and make the Insert with this settings. The setting can be changed for the current session only, so it doesn' influence other processes in your instance. After insertion, you can reset the setting, or simply close the session.

    Concerning
    Udo

  • Change the number of points per question - Captivate 5 Quiz

    Hello

    I created a Captivate questionnaire with 25 questions. Questions are drawn at random from a group of 130, and the issues are choice Multiple or more than one answer.

    I took the quiz on our Moodle site, but seems to have a problem with the score. Captivate is to give 10 points for each question that is answered correctly. Is it possible to change this to 1 point per good question?

    Please let me know if I can provide further information.

    Thank you

    You can adjust the number of points awarded for each question on the issue of properties inside Captivate.  The default value is 10 points, but you can set it to any integer.

  • Generating PDF based on input

    I'm working on creating an application for internal use at work. Users input a variety of information by using drop downs, text, check boxes, parts sketch entries and even use the camera. This information should then be generated in PDF format. The project is done in ActionScript.

    I found AlivePDF and purePDF, but it seems that they are intended to generate a side client PDF based on a predefined static entry.

    I would not be opposed to a solution that would go on a return to the corporate office server and generate the PDF file.

    Goal would be to find something free or very cheap as this project is a not-for-profit organization.

    Any suggestions? Thanks in advance!

    AlivePDF is just an API to generate a PDF file. QNX should have no impact on it. Not sure about the images. Do not remember if he can take a raw image or it took mx:Image.

  • How to generate PDF based w / drop-down menu

    If anyone can offer some guidance on how to generate a PDF based on the selection of the menu drop down.

    Click on registration to the coast and continue, press menu save and create pdf below to see what I mean in the link below.

    https://www.Teaforte.com/tea-menu/

    Thank you very much.

    Does your server support PHP scripts?

    PHP to format PDF - a simple solution for generating PDF using PHP

    Nancy O.

  • Mike 11 error: Floating Point of Division by zero error

    I use Windows 7 for running software MIKE11 . I used the same software to simulate the model in another Windows 7 PC operated and it worked correctly. But when I want to use the software in the PC, it returns me the error each time. How can I solve the problem?

    'Division by zero' errors are triggered by the application, not by Windows. You must ask the supplier for advice.

  • Generating lines based on the value of the column?

    Hi all

    I would like to know if there is a function that can help me in creating lines based on a column value and, if so, which. I'm on version 11.2.0.3.0

    for example, I have these data in the table:
    ID O A C
    1 5 3 5
    2 9 2 3

    Where ID is an identifier unique record and column C contains the number of records, I would have returned for this ID. In this example, the folder with the ID 1 would be repeated 5 times and the folder with the id 2 would be repeated 3 times. The result would look like this:

    ID O A C
    1 5 3 5
    1 5 3 5
    1 5 3 5
    1 5 3 5
    1 5 3 5
    2 9 2 3
    2 9 2 3
    2 9 2 3

    Column C contains the number of repetitions Records and is defined as a positive integer > = 1.

    Of course, in real life, the table contains (at this time) 41 M number of records and the value of C can vary between 1 and 554, hardcode on the example above values is not possible.

    Any pointers in the right direction are much appreciated.

    Kind regards
    Lennert
    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select 1 as id, 5 as c from dual union all
      2             select 2, 3 from dual)
      3  --
      4  select id, c
      5  from   t
      6  connect by level <= c
      7          and id = prior id
      8*         and prior sys_guid() is not null
    SQL> /
    
            ID          C
    ---------- ----------
             1          5
             1          5
             1          5
             1          5
             1          5
             2          3
             2          3
             2          3
    
    8 rows selected.
    
  • How to generate two pulses per cycle? PCI-6251/6255

    Hello. I want to generate two or more pulses per cycle like the timming diagram. This pulse will be used to trigger the sampling data.

    I am ussing the PCI-6251. The VI examples to counter outputs can easily generate the first line, but the second I have no idea. All information can help.

    Another problem could be the synchronization of this lines and data acquisition.

    Concerning

    Ivan C.

    I would like to use the digital outputs for this - just generate a continuous at 1 MHz clock using one of the counters and write the following in your digital output lines:

    H H H L L L L L L L

    H L H L L L L L L L

    If you want to use these signals to pick a different spot on the 625 x, you the output of wire in a PFI lines.

    Best regards

  • Sampling rate - too much data points

    Hello community,

    I use a sensor signal strength of pressure on DAQmx labview through 2014. My rate from the hardware synchronization function is 50 KHz. The samples per channel of timing and read screws are the same set to 5 Khz when the channels are a continuous sampling. The problem I'm having is that when I run labview for a few seconds, say 5 seconds, I'm half million points of data. I tried to run for 10 seconds and points were more than a million where it is difficult to analyze. I think that the vi generates too much data points and the buffer is large. Am I wrong? Can you please help me solve this problem?

    Kind regards

    Mike

    You are now ready to learn a little of the power of LabVIEW and data flow programming.  LabVIEW is an inherently parallel language - two loops can run independently and in parallel, allowing you to make time-sensitive (such as sampling data) and a lot of time (such as data logging and tracing) at the same time, using queues to pass data between the loops and ensure the buffering required.

    If you open LabVIEW and click on the file menu in the toolbar, and then select new... (the points are important!), you will be able to create new ones (VI) from the model.  Choose a Framework, Design Patterns, producer/consumer Design Pattern (data).  It's what you want to do.

    You basically set up a "pure DAQ Acquisition Loop" (without logging TDMS) as producer, creation of 5000-element arrays of data every tenth of a second (if you are sampling at 50 kHz).  You create a queue of data outside the loop of producer whose elements are an array of 1 D of waveforms (the output of your Read DAQmx) and instead to send the data to a waveform graph, you put it in the queue.

    You are under this loop, a parallel loop that gets the same queue and remove items.  This loop will be sitting idle (no time taking CPU) until the data is queued.  He then it takes away the poster and registers (logs) in a PDM file.  Either way, you should open the TDMS file before entering this loop (consumer), write to the file inside the loop and close the file when the loop exits.  Study the example of the VI, you create with the model and see how it works.

    The beauty of this is that you can certainly 'keep up' with the writing of the data points in a TDMS file to 50 kHz.  You might not be able to display all the points, but there is nothing to prevent you from data processing (by, say, decimating or "block average" it) to a more 'user-friendly' display (your eyes ' sees' a 50 KHz signal?) -you have a set of 100 msec prior to the next package arrives in the queue.  Also note that the loop of producer probably takes very little time CPU - most of the time the material is waiting for its clock to 'tick', collection of points in a buffer, then transferring to the loop.

    Now you can have your cake and the computer display, too.

    Bob Schor

  • How to generate redeclenchables wave AO leave encoder ABZ quadrature on LV8.0 so that Z-pulse restarts the form of wave and pulse A - B clock it

    Hard, I try to find a solution how to use external ABZ, quadrature encoder pulse to retrigger and clock repeatedly the same AO signals (and). A and B legumes should clock AO and Z-pulse wave should restart the wave early. Is this possible with card 6221? Can provide you the code example?

    I use LV8.0

    Thank you

    Kevin,

    Thank you for picking up the thread.

    I understand your example and I already had working direct synchronization of the AO and MAKE the waveforms using external impulses. The problem is that my application cannot invoke the correct number of A pulse will run same waveform for months. I have to use Z-pulse to maintain synchronization in the long term. That's why the task should be redeclenchables.

    I have made some progress since yesterday on the use of the example attached 'retriggerable_ao - NOR .vi' and the decoder external t.i. IC, which has transformed two 1024 A, B encoder in dish 4096 pulses/turn. My CO task then divides this frequency to 1024 (4 points per period). This regime of AO - redeclenchables DO so usually seems to work.

    The problem now is that this chip must have a clock (~ 100 kHz or more) to work, and I don't want to build generator external too.

    Y at - there no way to get all the signals of high frequency signals (100 kHz, 20 MHz or 20 MHz base time) USB-6221 Board any PFI available pine asuming that all of my commitments in Task-resource in this example are needed?

    I tried a lot of things yesterday, but all the clock signals are either committed or roads are anavailable. I don't understand why I can't tap into it?

    Any thoughts?

    Mikhail

  • How to make the data previously generated reuse vi?

    Attached VI is just a simple example for my problem. I want to generate some data (or read it thanks to a shared variable, etc, etc) and create statistics on these data. In this example, a histogram and value medium.

    Now, if I stop the VI & restart again, the first time that I generate a new data point, all old data is deleted the chart and indicators. I want to change my program, so he'll see actually yet all the data I have accumulated before the table.

    I know how to do for example in matlab:

    output = myfunction (output)

    so when I call this function, the first 'myfunction()' time it will generate the output array I can then move again on the next call so that the previously generated data will be used.

    So, how do I do that in Labview?

    Make a search for globals functional, which is based on the use of a shift register uninitialized for a while loop. You basically already have this if you simply delete the matrix constant which initializes the shift register holding the data table. It is a technique that was used before that global variables have been introduced. It's an old technique, but it is very effective and the basis for the Action engines. Jim Kring suggested a version no.-loop for LabVIEW 8.5.

    Note: You perform a comparison on floating-point values. As noted several times on this forum, it is doomed to failure because of how floating point numbers are stored in computers (this has nothing to do with LabVIEW).

  • Entered in text based NIDAQmx ao/StartTrigger PFI specification

    I'm trying to convert some traditional NIDAQ code to NIDAQmx, and I'm having a problem with the output of continuous waveform with an ao/StartTrigger.  I have a PCI 6251 running on Windows 7 multifunction data acquisition.

    The relevant part of my code is as follows (this is Pascal, TriggerEdge is defined as DAQmx_Val_Edge1_Falling)

    create a task

    status: = DAQmxCreateTask('', @ExposeBeamTaskHandle);
    If status = 0 then
    Start
    Set the output channels
    AOChannels: = BoardIdentifier +'/ ao0:1';
    Set up to +/-10 V.
    status: = DAQmxCreateAOVoltageChan (ExposeBeamTaskHandle, PChar (AOChannels),
    (- 10,0, 10.0, DAQmx_Val_VoltageUnits2_Volts, nil);
    Configure the input to the output of startup, use the beginning of analog output trigger default trigger
    status: = DAQmxCfgDigEdgeStartTrig (ExposeBeamTaskHandle, ' ao/StartTrigger', Trigger_Edge);

    Set trigger entries so that PFI6 is the input ao/StartTrigger value

    TerminalString: = "/" + BoardIdentifier + "/ ao/StartTrigger";
    TriggerString: ='/ ' + BoardIdentifier + ' / PFI6';
    Status: = DAQmxConnectTerms (PChar (TriggerString), PChar (TerminalString), DAQmx_Val_DoNotInvertPolarity);

    Set the sampling frequency
    status: = DAQmxCfgSampClkTiming (ExposeBeamTaskHandle,
    Nile, / / use the internal timer
    1000000/TimeStep, / / rate, in samples per second per channel
    DAQmx_Val_Rising, //rising edge of thec clock
    DAQmx_Val_AcquisitionType_FiniteSamps, //finite number of samples to acquire
    Buf_Points); number of output per channel

    status: = DAQmxWriteBinaryI16 (ExposeBeamTaskHandle,
    Buf_Points, //1 point per channel
    FAKE, //no autoupdate
    0 //no timeout... return immediately after written
    DAQmx_Val_GroupByScanNumber, //interleaved data
    @Buffer [0], //Pointer to the table
    @SampsWritten, number of samples actually wrote
    Nile); reserved for future use

    Status: = DAQmxStartTask (ExposeBeamTaskHandle);
    StartingTime: = time;
    While ((not done) and (time)
    Start
    status: = DAQmxIsTaskDone (ExposeBeamTaskHandle, @done);
    Application.ProcessMessages;
    end;
    Status: = DAQmxStopTask (ExposeBeamTaskHandle);

    +++++++++++++++++++++++++++++++++++++++++++++++++++++

    Relaxation is set independently by the wiring on the PFI6 PIN.

    If I comment the DAQmxCfgDigEdgeStartTrig command, I get the desired result.  However, the trigger does not work... (he did not work in OR-traditional DAQ).  I get various errors on DAQmxWriteBinaryI16 (- 89131, - or 89134-89137), which translate the particular route is already in use, or if I use/Dev1/PFI6 in DAQmxCfgDigEdgeStartTrig as the source and destination cannot be the same.

    I can't find examples in place NIDAQmx on how to configure a specific PFI as input for the ao/StartTrigger.

    Any help would be appreciated.

    Hi shiva,.

    The question you probably arises because of the following line of code:

    status:=DAQmxCfgDigEdgeStartTrig(ExposeBeamTaskHandle, 'ao/StartTrigger', Trigger_Edge);
    

    The function, DAQmxCfgDigEdgeStartTrig, carries a Terminal to the trigger to start AO; You cannot route the trigger to start AO himself.  Instead, you must specify PFI6 in this line:

    status:=DAQmxCfgDigEdgeStartTrig(ExposeBeamTaskHandle, 'PFI6', Trigger_Edge);
    

    DAQmx installs several examples in ANSI C on your machine.  The following example on your machine should briefly present what you're trying to do:

    \National Instruments\NI - DAQ\Examples\DAQmx ANSI C\Analog Out\Generate Voltage\Mult Volt updates-Int Clk - dig start

    With this configuration, you don't need the DAQmxConnectTerms function in your code.  This should help you squared away.

    Kind regards

Maybe you are looking for

  • Step by step instructions using airport Time Capsule as backup for my Mac

    Step by step instructions using airport Time Capsule 2 TB as backup for my Mac

  • Newby T430 and T420

    Hi all I hope that this forum will help me. I have a Lenovo T420 and aT430 T420 2640 M processor 2.8 GHz I7 8g RAM 3520 T430 I7 cpu @ 2.9 ghz 16 GB of ram SSD 840 evo 120 GB to start I put black 750 GB HD in two of them in the player using a cart, on

  • Convert a U8 array to a data type of LabView

    In my code, the entrance is a fixed-length U8 array reflecting the data in memory, I need to convert it to a predefined data type. For example, the first 2 elements U8 in the arrary must comvert a U16, then 4 U8 U32 data elements data. I wonder if th

  • How to reinstall CC PS and LR CC after formatting PC?

    Hello everyone, unfortunately I have to format my PC, I have a service charge of account Adobe LR and PS, reinstall everything should I do? Thank you

  • Nexus 1000v password recovery

    I'm trying to recover the password on a Nexus 1000v VSM I cloned from our direct environment and spin in a nested workstation environment.When I try to start the installation ISO VSM, it is completely ignored and crosses all straight to the login pag