Frequent / occurring more value

I'll try to find the station used for each code.
There should be ANY duplicate ID
If an ID used a station like as many times as another station I would return to the station with the most recent date. (if the date is same so just to randomly select a station)
In the example below
1 ID used station 2 so the answer is 2
2 ID used station 2 so the answer is 2
ID 3 used 5 and station 2 and they have the same date. then choose any station (2 or 5)
4 ID used use 4 so the answer is 4

CREATE TABLE DAN_LAU666
(ID     VARCHAR2(8),
PERIOD    VARCHAR2(8),
UNIT VARCHAR2(8),
DATES VARCHAR2(12),
STATION VARCHAR2(8)
) 

INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (1,'1201','GIMP','12/01/2012','5');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (1,'1202','CHIMP','12/01/2012','2');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (1,'1201','PIMP','13/01/2012','2');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (1,'1201','LIMP','12/01/2012','2');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (2,'1201','STIMP','12/01/2012','2');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (2,'1205','KIMP','13/01/2012','5');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (2,'1201','DIMP','12/01/2012','2');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (3,'1201','GIMP','12/01/2012','5');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (3,'1205','CHIMP','12/01/2012','2');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (3,'1205','KIMP','12/01/2012','5');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (3,'1205','STIMP','12/01/2012','2');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (4,'1301','MKT103','6/02/2013','36');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (4,'1302','COM15','5/02/2013','4');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (4,'1303','SSK130','5/02/2013','4');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (4,'1304','STA102','5/02/2013','4');
INSERT INTO DAN_LAU666 (ID, PERIOD,UNIT,DATES,STATION) VALUES (3,'1204','PSS110','25/03/2013','1');
Gives:
ID     PERIOD     UNIT     DATES           STATION
1     1201     GIMP     12/01/2012     5
1     1202     CHIMP     12/01/2012     2
1     1201     PIMP     13/01/2012     2
1     1201     LIMP     12/01/2012     2
2     1201     STIMP     12/01/2012     2
2     1205     KIMP     13/01/2012     5
2     1201     DIMP     12/01/2012     2
3     1201     GIMP     12/01/2012     5
3     1205     CHIMP     12/01/2012     2
3     1205     KIMP     12/01/2012     5
3     1205     STIMP     12/01/2012     2
4     1301     MKT103     6/02/2013     36
4     1302     COM15     5/02/2013     4
4     1303     SSK130     5/02/2013     4
4     1304     STA102     5/02/2013     4
3     1204     PSS110     25/03/2013     1
WANTED:
     
ID     MOST USED STATION
1     2
2     2
3     5
4     4
I tried this code in a previous similar request I had gave me, but it is not the correct values:
WITH got_r_num AS
(
SELECT A.ID, A.station
Rank () OVER (PARTITION OF A.station
ORDER OF COUNT (*) / / desc
, MAX (A.dates) / / DESC
) AS r_num
OF dan_lau666 A
GROUP OF A.ID, A.station
)
SELECT ID, station
OF got_r_num
WHERE r_num = 1
ORDER BY ID

uses oracle 10

This should do the work for you.

select max(b.id) id , max(b.station) station
  from (
select a.id, a.station, a.cnt, dense_rank() over (partition by id order by cnt desc) rnk
  from (
select distinct id, station, count(*) over (partition by id, station order by id) cnt
  from dan_lau666
) a
) b
where b.rnk = 1
group by id;

ID       STATION
-------- --------
1        2
2        2
3        5
4        4

Tags: Database

Similar Questions

  • Is it possible to find the two sentences into one pdf file? For example, I know the words 'Here' and 'the answer' occur more than once in my document, but only once on the same page. I'm looking for this page.

    Is it possible to find the two sentences into one pdf file? For example, I know the words 'Here' and 'the answer' occur more than once in my document, but only once on the same page. I'm looking for this page.

    I tried to do this by using the search but it will find only them, if they occur as a long chain, that is to say "Here's the answer" rather than how they occur in the document it is to say "Here 's" a bunch of information that leads you to 'the answer'. The search feature so standard did not help.

    Then I tried to do this by using the tool to delete (obviously not the application of writing!) because it allows me to search for multiple words or phrases, however it is not highlight what page both are found. I tried to turn on the preference to enable deletions of comments and even if it meant that I could then go through all the comments, it's still not faster than my document is more than 1,000 pages, which meant there were too many total comments for me to be able to easily identify which page had both.

    Any ideas?

    There is no built-in way to search for two strings and limited to show only the results that appear on the same page.

    It can be done by using a custom script, however.

  • How can I restrict a query to the right results where a value occurs more than once.

    I am trying to identify the data where a foreign key id appears several times for a report.   Usually, there is one line in the table, but sometimes there are several lines. I want only the line returned multiple results.  No matter where clause I think is illegal.

    Here's what I want:

    Select exempt_cert_id, count of tb_exempt_cert_zones (exempt_cert_id)

    where count (exempt_cert_id) > 1

    Exempt_cert_id group

    Try having count (*) > 1

    - -

    SELECT

    - -

    HTH - Mark D Powell.

  • How can I access more values wwv_flow.g_fnn of a unique region?

    I have a line for multi multi-region, each page in region where users can update a couple of values in one of the regions before submitting them for further processing.

    I use an apex collection to collect the data that I'm interested in and save ready for further processing, then pulling back as simple collection queries in a separate page.

    Specifically, it is something of 1 to 4 regions, under certain conditions (based on the number of distinct values are picked on a collection page, up to 4 simultaneously) each of them for a number of different parts, with each region being stores where part numbers are known that content will be organized, the quantities available at each location.

    The problem is, using more than 1 region, it seems that the values in the wwv_flow.g_fnn elements are available only for the last region questioned on the page.  I have to be able to return to the values of page for all 4 regions for comparison with the collection that they were chosen in upon entry to the page in to detect all changed user values (say, the user only wants to choose 5 of the 10 available in a location).

    The user sees the list of parts and quantities and locations of stores and makes the changes that I want to publish on the collection, do some validation (not necessarily in that order), and then call an update batch using the name of the collection as a key, to ensure that all or nothing, the updates occur.

    All of the examples I can find online seem to be for a page report 'region '.

    I suspect that the answer may be to create a report of disruption, so it's all in one region (which is is as a compromise) or to publish a second book of the second page of what that page looks like when the user hits submit and do the audits through collection 2 LESS treatment of collections 1 , or some other thing, but before I try it, I thought I'd see if someone has already solved it.

    Thanks for the pointers,

    Mark

    Mark_B_1123581321 wrote:

    I understand that I'm going to need more than 1 set of table with 1 set by region, but I was hoping I could find a way to deal with each in turn under the existing features.  Looks like the Apex can be simply reuse the same set of unique table whenever it renders a new region

    This is the case. APEX does support a tabular presentation (i.e. report classic region with the value column attributes display form controls + post ApplyMRU and ApplyMRD submit process) per page. There is therefore no way to specify to what results table corresponds to controls in a column or table set offsets for each region/report form.

    I just hoped that I could perhaps define the static region id in an API call, and then find that my references to values of apex_application.g_fnn have been miraculously pointing to the values of this region.

    Not possible, but you can create a feature request for it.

    In fact, in my case, we are limited to only 4 lines per region, will not go beyond 16 ranks.  And column wise, I don't need to go beyond c016, so this isn't a problem.

    I think I have to go on the road to javascript, which I suppose seems appropriate anyway.

    Is only 16 columns for the entire page or by related? According to the report is a problem: 4 * 16 = 64 > 50.

    If it is 16 for the page, then convert reports to generate the form using apex_item to specify the table for each column would be probably faster.

  • Visualization of more values on the graph of the DAQ card

    Hello

    I acquire a Signal using the data acquisition card, the problem is that I can view only a few values on the graph of a waveform. Guide kindly of me if I want to see the points more on the graphical waveform, what I would do in my programming window.

    Concerning

    I think that you just want to use a TABLE instead of a chart.  A graph has an associated history, so that it shows more that just the last data series acquired you and wrote to the curve.

  • SQL with parameter in SQL more value

    Hi the master Oracle,


    I have a request as described below that you run on SQL more.


    Select object_name, object_type from USER_OBJECTS WHERE last_ddl_time between trunc (sysdate)-1 and sysdate;


    I tried this script to be set, when I run it then SQL should ask two values.
    If I do not give any value then script should use by default as SYSDATE.

    Someone could please let me know how to do this?



    Kind regards
    Sandeep Sutar
    select object_name
          ,object_type
      from user_objects
    where trunc(last_ddl_time) between trunc(to_date(nvl(&1,sysdate))) -1 and to_date(nvl(&2,sysdate))
    
  • How to use Boolean as a constant push to add more values

    Hello everyone, I am trying to use a Boolean OK button and a constant to do something similar to the calculator project that I read in other posts. I scored $1.00, $0.25, button...  So now.  I just want to add the value of an indicator whenever I press the button.

    Is the closest I can get is displayed while I hold the button in and it goes to 0 as I realese it. I want that it add up every time his press.

    Thanks in advance

    Kevin

    Hi Kevin, this is Paul of engineering Applications at OR.  Try something like in my attachment.  You can use instructions of type of case to determine if a key has been pressed, and then assign this case real value.  Good luck with it

    .

  • How to get the maximum/more value in one line?

    I have a simple table view Pivot with dollars as a measure, a month on accounts on the rows and columns.  I want to emphasize the month that has the greatest value.  For example if the market value for the revenue account is for Jan, Feb 11, 50 Mar 10 and 0 for the rest of the month, then so I want to highlight the cell that contains 50 green. So, basically, I need to be able to identify the max value in a row in the PivotTable.

    If I add a max calculation, it returns the top value in all columns and rows. A calculation of rank also returns the rankings in all the columns and rows. How can I determine the largest value in a single row?

    Thank you

    J

    In general, go through measures based on level. Just tweak it like max (income per year)

    Just do it in the criteria tab and see how it works and I still thing you know how to

  • Dynamically add more values to existing poplist

    Greetings,

    instead of recreating a poplist, is it possible to add an extra value on the existing poplist dynamically?
    (Please note that there are hard-coded in the existing poplist values that do not exist in any table)

    Thank you
    D

    Hello

    See in the help (F1) Online Forms Builder for Add_List_Element() integrated.

    François

  • Exchange Mail store search reconciliation returns more values

    Hi guys,.

    I ran the calendar "Exchange Mail store search reconciliation" and returned the value of the store of e-mail successfully. Now I run again but not return values. Values existed on the Lookup.ExchangeReconciliation.MailStore has been cleaned.

    I need these values to provision an Exchange user. Is this ok?

    Thank you

    Can you check if the FQDN Admin: cn = oimuser, cn = Users, dc is contoso, dc = com has read access appropriate to the node "CN = Microsoft Exchange, CN = Services, CN = Configuration, dc is contoso, dc = com"?
    You can use any LDAP browser to check if you can register all these entries under this node.

  • Get more value from my table records

    Hi Experts,
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    
    SQL> WITH T AS
      2  (
      3  SELECT  1 ID,'1OIKL' VAL,1 FLAG FROM DUAL UNION ALL
      4  SELECT 2,'9IUY',0 FROM DUAL UNION ALL
      5  SELECT 3,'9IUK',0 FROM DUAL UNION ALL
      6  SELECT 4,'9IUS',0 FROM DUAL UNION ALL
      7  SELECT 1,'1OIKL',0 FLAG FROM DUAL
      8  )SELECT * FROM T;
    
            ID VAL         FLAG
    ---------- ----- ----------
             1 1OIKL          1
             2 9IUY           0
             3 9IUK           0
             4 9IUS           0
             1 1OIKL          0
    
    SQL>
    I need the unique output like VAL result with the biggest FLAG
            ID VAL         FLAG
    ---------- ----- ----------
             1 1OIKL          1
             2 9IUY           0
             3 9IUK           0
             4 9IUS           0
    SQL>
    Thank you

    Published by: DB-user11904889, March 24, 2010 15:51
    Code field included in the values of the table

    Try:

    SQL> create table T AS
      2  SELECT 1 PK, 1 ID,'1OIKL' VAL,1 FLAG FROM DUAL UNION ALL
      3  SELECT 2,2,'9IUY',0 FROM DUAL UNION ALL
      4  SELECT 3,3,'9IUK',0 FROM DUAL UNION ALL
      5  SELECT 4,4,'9IUS',0 FROM DUAL UNION ALL
      6  SELECT 5,1,'1OIKL',0 FLAG FROM DUAL;
    
    Table created.
    
    SQL> select * from t;
    
            PK         ID VAL         FLAG
    ---------- ---------- ----- ----------
             1          1 1OIKL          1
             2          2 9IUY           0
             3          3 9IUK           0
             4          4 9IUS           0
             5          1 1OIKL          0
    
    5 rows selected.
    
    SQL> delete from t t1
      2  where exists ( select null
      3                 from   t t2
      4                 where  t1.val = t2.val
      5                 and    t1.flag < t2.flag
      6               );
    
    1 row deleted.
    
    SQL> select * from t;
    
            PK         ID VAL         FLAG
    ---------- ---------- ----- ----------
             1          1 1OIKL          1
             2          2 9IUY           0
             3          3 9IUK           0
             4          4 9IUS           0
    
    4 rows selected.
    
  • iOS default keyboard causes Apps to the freeze on more than 7

    The software keyboard appears to cause random app freezes. It's the APPLE keyboard. The gel seems to occur more frequently in the predictive text or AutoCorrect scenarios. It also occurs when you move the selector text. In addition, the same application / combinations of words seem to trigger the gel several times. More trigger-happy is hashtags in facebook.  In addition, type point 4 below, Frost occurred during after erasing an accidental space after the word "effective" here is what I tried:

    1: turn off predictive text.

    2: more backup on my 6s and the problem was not persistent.

    3: reset and recovered my newest 7s and the problem was persistent.

    4: write notes in Evernote and sticking them in the fields of text on other applications. Of workaround prevents me from losing the entered text before, but does not freeze.

    I have a very similar problem.  It is reproducible even after power off or hard reset (power and set "home" button).

    For example, I found today that it happened all the time when I tried to type "Otley" in a text message.  The keyboard froze as soon as that word was typed.  Normal service has resumed after I close the application.

    I tried the option Dictionary reset without any benefit.

    I'm on an iPhone SE with 10.5.2

  • Frequent crashes on all operating systems

    Hi, I think that what I have is a hardware problem.

    I have a 2012 end iMac that breaks down several times a day, but after some time after installation of operating systems, it becomes slower. I posted my problem in many places, but only in the context of bootcamp, because I haven't used OS x that much. I wanted to get Windows to work if I could go back and forth between the two operating systems and after that it does not work most of the time I use my old computer and tempting to ignore the problem.

    First, I will describe what happens under Windows since I saw him most. A program freezes. At this point, I noticed that I can't quit all applications. My internet disconnects. Other programs are starting to freeze. When I try to use the start menu, it does nothing and almost everything freezes. That's when I realize what is about to happen. If I wait about an hour, my computer will eventually BSoD, usually with a kernel_data_inpage_error, but sometimes with others. The strangest part of this all is that I can use my mouse long after all broke, and sometimes I can even use, say, Chrome, although certainly, I can't go out, and when I try to go to a website he tries, but fails to cause that there is not WiFi. Sometimes it shows which driver caused the exception (varies, of course), sometimes not. This happens with or without devices, but it * maybe (probably not) * occur more frequently when I have a connected USB drive. What I tried: install different versions of Windows 15 + total time, mixing how the drive is formatted (bootcamp partition vs Windows install wipes player then internet OS X recovery), version of Windows, diskchk + SeaTools (as say all is well), etc. there is no landfill and there is no log in Event Viewer, no matter how to configure it.

    I know it of an Apple forum, for most of you probably don't specialize in Windows, which is what I have observed most, but I had no luck on the forums of Windows, if I have not a thread going right now. I can't find anyone else who has this problem. On OS X, but I don't think it was as much before, lately it's been blocked frequently, and the symptoms are what I imagine would be a version Mac - ey from what I see on Windows. An individual program will freeze, saying Dota 2. I can still pass the screens with ctrl-arrow, but after a minute that breaks. Things are starting to disappear and finally my screen turns black with only my cursor. I've not waited for hours to see what happens at the end, but I'm guessing it will be Mac version of a BSoD. I checked the console and I saw nothing that stands out, but I'm not nearly as much experience compared to the event viewer.

    What can I do to try to solve this problem? Sometimes the driver BSoD watch is partmgr.sys, suggesting it has something to do with the hard drive itself, but as an iMac, I can not exactly crack it open and take a look at the cables. Unfortunately I don't have extra money now to buy an external hard drive to install Windows to test. Unfortunately, my warranty has long been upward, which is really frustrating because that's happened since I got it. I should have pursued the issue more away a long time ago. If I explain my problem do you think I could always send it to check?

    Thanks for reading. Any idea is appreciated.

    There is a separate instance of Boot Camp.  I asked that this thread moved here.

    You might want the extended hardware test that came with the Mac.

    If no problem is there, and a deletion and installation of Windows and Mac OS X give the same breaks down, you can have a RAM problem.

    Note the spinning beach balls are not always signs of a problem.  You can simply have run out of hard drive space.

    http://www.etrecheck.com on Mac OS X is a good diagnostic tool that can tell us if you installed anything on Mac OS X, which can be it slows down, or if you are near capacity.

  • Incorrect SCXI all the playback channels after running for more than 30 minutes

    I have a SCXI-1001 module. I use a thermocouple module (1102, breakout box 1300), input analog (off 2, map of 1100, 1300 in small groups), analog output (1124 map, 1325 breakout) and a relay (card 1160, breakout 1324). I'm using labview 2009. I created my channels manually to read all channels, I need about 1 task for entries of thermocouple and analog, 1 analog and 1 for task task for the output relay (total 3 tasks). Each task comes into contact with the SCXI area in a different section of a timed sequence. I read all my channels with precision for 30 minutes but then all of a sudden they stop reading accurately and all thermocouples read the same incorrect value as well as all analog input channels. I can't change the output channels either.

    The problem occurs more quickly if I increase the clock frequency. There are no errors showing when this problem occurs.

    What is an interaction of hardware failure or a software.

    Any help would be greatly appreciated. I also need to resolve this issue quickly because it is delaying the test.

    Thanks for your help

    Tim

    Thank you all for your response. I managed to solve the problem. It was a problem with the start of the task and to connect the clocks for different tasks. I've included only a single task to start my unstable code in the source code as for posed multiple startup tasks. However, I started my slave tasks (analog and digital outputs) before starting my master's work (analougue entered). This seems to have solved the problem. I intend to go more far by adding clocks at 2 slave atsks and linking them to the task of master.

    I used the sequence as part of documentation. Each links to sequence number to another sheet that I have has a flowchart to say what is each part. As you say there is no need to put in a sequence and do so limit labviews own data stream. I'll remove the sequences and put my documentation on the codes in the code directly because it is made in the examples of labview.

    Thank you for your help

    Tim

  • Microsoft error reporting occurs again with several service packs that need to be sent in an error report. This happens on some machines and not others on a school campus.

    I noticed this error that occur more frequently on multiple machines only when connected to an administrator account. The error on some machines, but not the others if they were all created from the same image of a HD master.

    I haven't noticed any malfunction of applications, but this error occurs, breed a little bit is set.
    Images of the error:

    http://imgur.com/delete/6acg8Ddt2V
    http://imgur.com/delete/3auBhSinkL
    http://imgur.com/delete/m1Po7IPlZE

    ddefreit,
    Because it is related to a deployment scenario and is involving multiple machines, you will need to check with the TechNet site for the appropriate support.
    http://TechNet.Microsoft.com/en-us/Windows/bb264763.aspx
    Mike - Engineer Support Microsoft Answers
    Visit our Microsoft answers feedback Forum and let us know what you think.

Maybe you are looking for

  • ac635tu: upgrade RAM in HP 15-ac635tu

    The upgrade of RAM the HP PC laptop 15-ac635tu, because the tour does not access RAM slot on the bottom window. Any repair with illustrations on properly disassemble the laptop will help me much... The specification states that the Tower has an empty

  • Pavilion 13 p111nrx2: Win10-upgrade, Null, Fax - HP Officejet 4630 series - error 0 x 80070490

    Win10-update, Null, Fax - HP Officejet 4630 series - error 0 x 80070490 Every day or two, I get this Windows Update failed error (see above). Printer: HP 4630 all-in-one Computer: HP Pavilion 13 p111nrx2 Model: E9L41UA Operating system: Windows 10 64

  • Error reading the attached viSA-1073807339 using Subvi, but why?

    Hello First of all, thanks to all who respond! I read N9020A Agilent MXA Signal Analyzer data.  It is successful if a Subvi is used to playback VISA; otherwise "Read Error-1073807339 VISA' rears its ugly little head.»  The Agilent gives the message "

  • LabVIEW GPIB Prologix error 1073676294

    Hello I get an error code 1073676294 on one of my GPIB read the steps. It is a GPIB Prologix. The LabVIEW program is supposed to Lock-in conspiracy in a graphic and graphic o-scope in a different voltage. The Setup is for piezoelectric measurements u

  • Why is the windows genuine validation software not supported under XP

    I have a legit software, but I need to validate it before I can get the new version of media player so I can watch digital copies of my movies on my laptop, I get an error saying: there need a DRM update I have try and the server does not work so whe