Get the value of the following line in the game ordered under certain conditions

Do not know if my best subject line sums up what I do :)


Oracle DB 12 c (I think 12.1.2)


I have a table with the names of people and DOB with a few keystrokes. It is assumed that this person is the 'same' first_name, last_name, birth_day/month/year are identical

drop table people;

create table persons

(

first name varchar2 (30),

VARCHAR2 (30) last_name,.

birth_month varchar2 (2),

birth_day varchar2 (2),

birth_year varchar2 (4).

keyVal number

);

insert into values('JOHN','SMITH','10','10','1974',1) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

insert into values('JOHN','SMITH','10','10','1974',2) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

insert into values('JANE','SMITH','10','10','1974',3) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

insert into values('JANE','DOE','10','10','1974',4) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

insert into values('JANE','DOE','10','10','1974',5) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

insert into values('ERIC','DOE','11','10','1975',6) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

insert into values('ERIC','DOE','11','10','1975',7) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

insert into values('ERIC','DOE','11','10','1975',8) people (first_name, last_name, birth_month, birth_day, birth_year, keyval);

I want to see the following output:

first_name, last_name, birth_month, birth_day, birth_year, keyval_min, keyval_other

JOHNSMITH101019741 2
JANEDOE101019744 5
ERICDOE111019756 7
ERICDOE111019756 8

1. the output will display only those who appear at least twice in the original table

2. If the person appears twice in the original table, the output will only one result where first keyval will be min two; second keyval will be the other value;

3. If the person has 3 times or more (n times, for example), each line of output will be keyval_min of all keyvals followed by the other value keyval. Total of n-1 lines

It's very large 100 + M and the processing time is important.

Hope I explained it well.

Hello

This sounds like a job for analytical functions.

If the same person has N rows in the table, the output should be N - 1 lines.  You can use the ROW_NUMBER analytic function to assign numbers (1, 2, 3,...) to each line and do not display the lines nuimbered 1.

On each line, you must prove the keyval lowest for this person.  The analytical MIN function can do this.

Here's one way:

WITH got_analytics AS

(

SELECT first_name, last_name, birth_month, birth_day, birth_year, keyval

, ROW_NUMBER () OVER (PARTITION BY first_name, last_name, birth_month, birth_day, birth_year)

ORDER BY keyval

) AS r_num

, MIN (keyval) OVER (PARTITION BY first_name, last_name, birth_month, birth_day, birth_year)

) AS keyval_min

AMONG the people

)

SELECT first_name, last_name, birth_month, birth_day, birth_year

keyval_min

keyval AS keyval_other

OF got_analytics

WHERE r_num > 1

ORDER BY first_name, last_name, birth_month, birth_day, birth_year

r_num

;

Use the data DATE to the date information type.  With the help of 3 columns separate NUMBERS will result in complicated, ineffective, code errors and invalid data.

Tags: Database

Similar Questions

  • imaqReadAVIFrame retrieves the empty image under certain conditions?

    Hello

    I'm having a problem where imaqReadAVIFrame (.) is the white recovery (all black images) under certain conditions.  The conditions seem to be when the height of the AVI file is equal to or greater than the width and the height is an odd number.  AVI files created by using the various AVI NI Vision (IMAQ 4.6.1, IMAQdx 4.6.1) functions in an application created in CVI 2012 on a computer running Windows 7 64 bit.  AVI files use MJPEG compressor, and they play back fine in an external program like VLC or Windows Media Player.  Any ideas on what this could be?  My solution for now is to not to allow the creation of AVI files where the height is odd and equal to or greater than the width that is not a boring restriction, but it seems like there's something weird happens with imaqReadAVIFrame().  I can provide some AVI files if necessary, but they are 16 + MB each.

    TStanley,

    I managed to reproduce what you see with your .avi files in a program I wrote.  I built a LabVIEW program that creates an AVI file which can be saved to memory and then uses code from the example finder to read who created the file.  I build the file to your specifications at the height is greater than the width, and the height being an odd number of pixels.  Something interesting about this, however, is that it seems to be a point where an odd height is acceptable.  Once you go below the height of 291 pixels, any odd height then works.  The files that I used are written as read in LabVIEW, but that the configuration should be irrelevant because we are seeing the same issue.  In addition, LabVIEW and LabWindows CVI calling the same dll to actually set up the code.

    In this, I think this question arises from the nature of the way you compress the. AVI file.  If you are interested to read a bit more about it, a useful link can be found here:

    http://www.manifest-tech.com/media_pc/avi_formats.htm

    However, what I think is happening, is it that MJPEG file compression format translates into creating files that cannot be read by our software unless the height in pixels is a multiple of 2 or the size of the file is below a certain limit.  To fix that, there is a simple solution. Compress the file with any of the other compression methods available (DV video, Cinepak Codec, codec Intel IYUV, Microsoft RLE, Microsoft Video) and you will be able to open the file without the black screen.  This worked for me and should solve all your problems.  I hope this gives you a bit of insight.

    Kind regards

    Keith M

    Technical sales engineer

  • Update on the table by extracting the data from the table even under certain conditions

    Hi Experts,

    I have the table EMP which currently has 6 entries.

    EMP_SYS BATCH_NO JOIN_DATE LOGIN_ID STATUS FLAG

    1 FEBRUARY 10 PROD 84 Y IND123 ABC

    DEV 1-23 APRIL 98 Y IND123 ABC

    2 12 APRIL PROD 98 Y IND123 ABC

    2 2 APRIL DEV 98 Y IND123 ABC

    3 13 APRIL PROD 98 Y IND123 ABC

    3 3 APRIL DEV 98 Y IND123 ABC

    CONDITION: I need to take lines which has the minimum BATCH_NO for each of the EMP_SYS

    for example,.

    1 FEBRUARY 10 PROD 84 Y IND123 ABC

    DEV 1-23 APRIL 98 Y IND123 ABC

    For the above two lines, I need to update the status of DEF. How to select this criterion and update in the same query?

    Currently, I used the query to select the minimum BATCH_NO for each of the EMP_SYS below.

    SELECT EMP_SYS, BATCH_NO, JOIN_DATE, FLAG, LOGIN_ID, STATUS

    Of

    (

    EMP_SYS, BATCH_NO, JOIN_DATE, FLAG, LOGIN_ID, STATUS, SELECT ROW_NUMBER)

    COURSE NR (PARTITION BY ORDER OF EMP_SYS OF EMP_SYS)

    FROM EMP

    WHEN STATUS = 'ABC' AND FLAG = "Y".

    )

    WHERE

    NR = 1;

    If I try to use the update on the above query statement... It updates every 6 rows instead of 2 rows.

    Please suggest me a way to update only the two lines that has the minimum BATCH_NO for each of the EMP_SYS.

    But is possible to write the query without using the Group of?

    Update e EMP

    set STATUS = "DEF".

    where BATCH_NO = (select min (BATCH_NO) from EMP I where STATUS = 'ABC' AND FLAG = 'Y' and i.emp_sys = e.emp_sys)

  • Problem to get the startup-config under the privilege level

    Hi guys

    I use the level of privilege 15.2 and in this version, that I can not get the startup-config under some of IOS (in this case, IE 7)

    I have no problem to get it from the earlier version, also to 15.1

    Router #sh privileges

    Current privilege level is 7

    Router #sh startup-config

    With the help of 4414 262136 bytes

    % Error opening nvram: / startup-config (Permission denied)

    Config:

    privilege exec level 7 show startup-config

    privilege level exec 15 see the configuration

    show privileges exec level 1

    When I added cmd ' privilege exec level 7 show startup-config ', IOS generated automatically new line "privilege exec 15 level show configuration.

    seems that there must be an "improvement" under versions of 15.2

    Any ideas?

    Thank you

    Pet

    Hello

    I have faced the same problem and opened a folder. Please find the answer I get from the TAC:

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

    This is designed by design as a security measure. Starting in the new versions of IOS, the privilege level of access to system files must be configured separately. There are two options to solve this problem:

    (1) run the command at the prompt to activate it.

    (2) set the privilege level of the file system via the config command "file privilege X" with X the number of privilege level

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

    Hope that helps.

    Best regards.

    Karim

  • Cannot get the games to load

    I can't get the game to load Facebook and I know this has something to do w / flash. (I use IE 7 (64-bit) and my flash is updated to the latest version 11.6.602.168.

    I uninstalled flash and when I did, when I was on Fb and you need to click on a link to help friends on games, (games I play are Fv, Sims, Candy Crush and family farms), it would be the actual load fast. I couldn't play the game (s) until the flash has been loaded. I go to install flash & as soon as I did, nothing loads. I completely deleted and reinstalled flash twice.

    I know it's a problem w / flash because I have seen/read another post ppls in front for exactly the same problem.

    This needs fixed bug and how to fix it?

    follow the directions and your flash drive edition: http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-windows.html

    When it is complete, download and install flash player: http://get.adobe.com/flashplayer/

    PS uncheck mcafee unless you are certain you want.

  • How to get the game that require a resolution of 1024 x 768 to work on my book?

    Hello

    How can I get the games requiring work of resolution 1024 x 768 on booklet?
    Any solution for this?

    Thank you

    Hello

    I assume you mean on the Libretto W100.
    The device supports a 16:9 screen with a resolution of 1024 x 600.
    If unfortunately 1024 x 768 is not supported

  • How to get the game of ball of ink on Windows XP-based computer

    How to get the game of ball of ink on Windows XP based computer.

    Hello
    Also try this freeware site:
    http://www.bestvistadownloads.com/download-ink-ball-game-software.html
    B Eddie

  • How can I get the game controller that you want to correlate to the keyboard commands?

    How can I get the game controller that you want to correlate to the keyboard commands?

    You may need to use the profiling software that comes with any game controller you are using.

    Some software controller has a library of game titles with default button/key configurations that

    You can change in the software according to your desires.

    -The software will need to navigate you to the games executable ( .exe ) from in the profiling software, which allows for the profile that you create in order to be recognized when you load the game in question.

    You can create orders, or simply assign a key combination, of a particular button on the controller

    and save the profile.

    -If the controller does not have a profiling software available for download, you may be stuck

    with some default orders can work with this controller and as a monopoly$ insinuated oft

    the controller XBOX games PC as a default configuration, a few years ago, it could mean

    your controller can be very useful if it is not programmed to emulate the XBOX controller.

    -If your controller is programmed to emulate the XBOX controller (like many recent controllers)

    It should be just a matter of changing the configuration in game controller options.

  • Satellite A500 PSAM3A - how to get the HARD market under Vista 64-bit disk Protection System

    Hello

    I would like to know how to get the HARD drive Protection system up and running under Vista Home Premium 64 bit operating system. I downloaded the program 64 bit of Toshiba for this program and install it I tried but doesn't seem to work. I have uninstalled and try to install the program, but still does not work.

    Unable to find the problem, why it won't work. If anyone knows how to solve this problem it would be a great
    help for me. If anyone knows how to solve this problem please answer me as soon as possible.

    Thank you for your time.

    Kind regards
    Nigel.

    Hello!

    What you downloaded exactly on the Toshiba site?

    As written Akuma you must install first added value Package you will find also on the Toshiba site. Check this box!

    An interesting thing: it does not work if you are using the preinstalled operating system? It should have everything installed for your laptop.

    Good bye

  • Get the next row in the set of results under certain conditions

    Hello
    I have a result set with a column in ascending order of the numbers. Now, I want to compare these numbers to a value. If one of the numbers exactly matches the value then all is well and I use number < = value as a condition. If the value does not match exactly I want to get the next number in the result as well. A short example

    NB in resultset
    41
    82
    123
    164
    205
    246

    To compare with value = 200, I want to have

    41
    82
    123
    164
    205

    as a result.

    To compare with value = 164, I want to have

    41
    82
    123
    164

    Thanks for any advice.
    Carsten cordially

    You can use analytical functions for that. There are several options, here is one.

    with testdata as (select 41 num from dual union all
                      select 82  num from dual union all
                      select 123 num from dual union all
                      select 164 num from dual union all
                      select 205 num from dual union all
                      select 246 num from dual)
    /* end of test data creation */
        ,resulttab as (select num, nvl(lag(num) over (order by num) ,0) next_num
                       from testdata )
    select num
    from resulttab
    where next_num < 200 ;
    NUM
    ---
    41
    82
    123
    164
    205
    
    ...
    select num
    from resulttab
    where next_num < 164 ;
    41
    82
    123
    164
    
  • How can I get the game to Windows Vista, Microsoft Tinker back...?

    I had downloaded the Publisher Microsoft Tinker and don't like it and so I uninstalled it and I lost the game. I need to know how to retrieve. Can someone help me out here? I tried to get answers from other sites of computer on their forums, but nothing so far.

    Hi Gamerchic82,

    Thank you for using Microsoft Vista answers Forum!

    To play Tinker, you must run Windows Vista Ultimate, and you must download Tinker as a Windows Ultimate Extra. For more information, see how Windows Ultimate Extras downloads and services?

    If please reply and let us know if your problem is resolved or if you need more help.

    David O
    Microsoft Answers Support Engineer
    Visit our and tell us what you think.

  • I can't get the games to run after the upgrade from Windows 7 to Windows 8

    I have updated to Windows 8, but can not get Windows 7 games to run on this new program. How can I do this?

    If you are referring to the built-in games that were in Windows 7, as they are not available in Windows 8. Instead, there are a few free games available on the Windows Store product Microsoft applications (in your Start Menu). Card by Microsoft games are called Microsoft Solitaire Collection, there are also Microsoft Mahjong and Minesweeper from Microsoft. You should note that these are different from what you had previously.

    You can also search applications game 3rd party on the Windows store.

    If these aren't the games you were talking about, please provide details of those you want to say.

  • How can I get the games installed at the factory as a free cell, stings etc restored or recovered, they went from windows vista system?

    I don't know what happened to them and I'm not the sharpest on a computer but ok they are no where on the computer and I do not know exactly when they disappeared so I can't do a restore of the entire system.

    Click Start or press the Windows key and type optionalfeatures.exe then the .

    When the Windows features dialog box comes up and ends to populate its list, check the State of the option of games .

    1. If it is checked, uncheck the box, click OK , and then restart the computer. Retrace your steps for this dialog box and save. This should uninstall and reinstall all the games that you have controlled.
    2. If it is not checked, check it. This will install the package of games in option.
  • How to get the game Xbox 360 PC wireless receiver working on Windows 8?

    I recently upgraded to Windows 8 Pro x 64 and discovered that the game wireless Xbox 360 PC reception does not work. I tried setting up as I did for Windows 7, but I can't find 'Windows controller for common class window' to update the driver.

    Is it possible to make it work again like on Windows 7?

    Hey everyone I made a video explaining how to do it.

    http://www.YouTube.com/watch?v=4_PFdPmdNiM

    yout welcome

  • Under certain conditions see the popup on page (fragment) charge

    Hi Experts,

    We have an obligation to show a popup on the page load, if a certain condition is true.

    I have two fragments (home.jsff and profile.jsff). Initially when the user login, home.jsff is indicated and that there should be no popup.

    When the user goes to profile.jsff and save the changes, it must first redirect to home.jsff and show a popup with the confirmation message.

    I can't create a fragment separated for the popup where we need to redirect to profile.jsff and then redirect to home.jsff as said the requirement that the popup should display the content of home.jsff in the background.

    Also I can't use showPopup behavior during the loading of the page because it's a jsff.

    Please suggest how to implement this.

    Thanks in advance.

    Best regards

    Saurabh

    ... There's an even simpler option

    1. Add a hidden from the fragment output text element

    2 bind the output components text 'value' property to a bean property of manage (pair of getter/setter)

    3. when the getter of the value method is called, check the indicator that you defined for if you want to display the context menu or not

    4. If the indicator is such that the popup needs to be displayed, run the Java Popup

    4.a search the component RichPopup

    4.b set flags of the popup

    4.c unset flag to display the pop-up window (for the next time you need to put it)

    4.d see the popup

    Frank

Maybe you are looking for

  • MacBook does not start (even in safe mode)

    Hi, I have a MacBook pro that won't start. When I turn it on, I hear the ring of priming, but then the screen stays black. I tried all possible troubleshooting recommendation, that I could find on the internet, but nothing makes a difference. None of

  • Hard drive and RAM for Pavilion dv6 - 6123cl

    Hello! I want to change my ram and my hard drive. The ram will be 8 GB and 2 TB drive, I wonder if I used the hard drive, if supported? and with regard to the ram, if I have to buy one that is compatible or anyone served me?Thank you! : smileywink:

  • I'm not able to find the black ink cartridge CH561h Hp122 near my place in Mumbai

    I'm not able to find hp122 black ink cartridge for ch561h near my position in India for my printer hp dekjet 1050 A all in one set then please let me know what other model cartridge n ° would work for my printer my hp 122 was the embarrassment. Other

  • Overall CVP: SIP closing Service

    Hello We try to get the work of comprehensive model of CVP 4.0 and little, we are stuck at the level of the server to call. We use control of SIP calls based and in the server to call CVP, lit the SIP/IVR/ICM service. After installation and applying

  • Memory lost over time in my C: drive

    I noticed over time that I lost memory over time in my C: drive. I have about 500 GB, now showing only about 3 GB of space left. I have some downloads, but nowhere near 400 GB (I had pictures, but they deleted the hard drive that saved the GB) What w