Fill the third variable according to date

Dear all,

In my database, visitdate and the variable pat_id is here. I want to fill the third variable one that went first, and then we V1, then V2, V3, V4 etc...
If the patient went to the same date and same type of visit must be here (e.g.P004)


type of visitdate pat_id
P001 23/03/2010 V1
27/05/2012 V3 P001
P001 07/27/2010 V2
P002 05/11/2010 V1
P002 05/09/2009 V3
P003 07/27/2010 V1
P004 23/03/2010 V1
P004 23/03/2010 V1
P004 07/27/2010 V2
P004 07/27/2011 V3


Thanks in advance for your help

Hello

This sounds like a job for the analytical DENSE_RANK function.

SELECT    pat_id
,       visitdate
,       'V' || TO_CHAR ( DENSE_RANK ()
                             OVER ( PARTITION BY  pat_id
                                 ORDER BY         visitdate
                        )
                )  AS type
FROM      table_x
ORDER BY  pat_id     -- statement ORDER BY clause is optional
,            visitdate
;

If you would care to post CREATE TABLE and INSERT instructions for the sample data, and then I could test it.
See the FAQ forum {message identifier: = 9360002}

Published by: Frank Kulash on 29 January 2013 09:19

Tags: Database

Similar Questions

  • Resize an image to fill the canvas size according to height?

    Hi guys,.

    Is it possible to resize a picture to fill the canvas size according to height?

    Currently when I place an image, it fits on width, being a landscape on a canvas portrait image I need to fill the height.

    Any suggestions on the best way to do it, maybe an action?

    Thank you

    Gavin

    If the image containing or the picture may vary in dimensions/dimensions a Scripting approach would seem prudent.

    In the contrary case, a conditional Action may be enough.

  • How to swap two values without using the third variable using the procedure

    How to exchange the two values without using the third variable using the procedure?

    In a procedure using two mode we pass two values A = x and B = y, and let us pass parameters to receive the output has A = y and B = x without using the third variable

    Published by: Millar on August 19, 2012 11:23

    Your question doesn't seem wise. As written, there is no reason to a third variable, just

    CREATE OR REPLACE PROCEDURE(
      x IN number,
      y IN number,
      a OUT number,
      b OUT number
    )
    AS
    BEGIN
      a := y;
      b := x;
    END;
    

    If it's an interview question, I suspect that the intention was that you had two settings IN OUT and you wanted to swap the values without the help of a third variable.

    Justin

  • Filling the prompt values according to other dashboard invites

    Hi friends,
    In my scenariao, I need two guests of dashboard in my report. (1) exercise 2) date range

    When the user selects an exercise of the first prompt, another prompt that is falling down and "in between" operator defined, should show only dates coming in this exercise. I don't use calendar here coz we only 26 Date for a year, and we want the user to select dates only from these dates.

    Appreciate your help

    Hi Toony, if I understand your situation, well, it's a solution. Correct me if I'm wrong.

    If you want to restrict the list items in the second prompt according to the first prompt, you must check the box to 'Coercion' to line 2.
    When you select an item in the Prompt1, the constraint for 2 Guest option, ensures to fill only list items that fall into the selected category of guest 1.
    Ex: If Prompt 1 for the country and fast 2 belongs to the States. When you select US Prompt 1, then 2 Prompt shows only the United States.

    If this isn't what you wanted, then you must explicitly pass the presentation 1 prompt Variable to the fast 2.

    Taking the example above, States and countries.
    Pass the value read from the country in a variable of presentation - pCountry and save this prompt as guest country

    Create an another command prompt to the States. In the Show menu pull-down select the results of SQL and write a query something like that.
    (Select distinct States of where country = ' @{pCountry} {U.S.}) "). Save this prompt under the guest of the State.

    The way it works is when you select a country from the country prompt and press the GO button, it passes the variable pCountry for prompt presentation of State and triggers the query to fill the drop down.

    I hope this helps.

    SAI

    Published by: Sai Kumar Reddiboyina, October 17, 2008 07:26

  • Filling the first page second page data

    Hi all

    I developed a demo.cfm page that has the grid table. I display the table grid of database data.
    Each row of the table in the grid has a button change. Click on edit button redirects to another page that contains text fields whose names are similar to grid table headers.

    As soon as the user clicks on a particular line of the grid edit table button. Button clicked line values must be entered in the second text of page fields.

    Ex: Grid table demo.cfm contains the following data
    Name Age Sex Address

    1. 22 M Edit XYZ xyz

    When the user clicks Edit button form is submitted and in the second page text boxes him clicked on change line of link values need to be filled.
    Here we clicked on the first edit of a line button then second page text fields are filled with the values of line first.

    NAME: xyz
    Age: 22
    Sex: M
    Address: xyz

    Similarly, regardless of the line edit button than row data must be completed on the second page of the screen areas.


    How to solve this problem.

    Can someone help me solve this problem.

    Change the link must go to the second page details specific to this line.

    Do something like:


    Edit

    Then, in your form on the second page, you fill in the form as:



    Clearly this all depends on your so-called fields etc (I guessed right) and also, you will need to check some variables exist or not while it throws an error when they are not - but that's a different question.

    Good luck.

  • How can I dynamically select the shared Variable API programming data type?

    I am trying to create a configuration of open connections of variable shared using the programming API. It seems to me that the cleanest way to do would be to put one "open and check" routine in a loop, then call it for each variable in the library.

    The question that I am running is that I have different types of data in my library (to help a server Modbus i/o and data types 'boolean' and 'single' in my library.) How can I dynamically select the data type of the shared variable API?

    See the attached snipit.

    Thank you

    What I ended up doing was doing a Subvi to open, read, write, and close each data type, I use the packaged in 4 polymorphic SubVIs (polymorphic Open, read, etc...)

    Now all I have to do I drop in the polymorphic Subvi and it switches automatically to the appropriate data type

  • by the way the Session variable of type DATE for opaque filter data view

    Hello world

    You guys can help me please by passing the session variable of DATE in physical layer 'view opaque' data type filter RPD to Oracle database

    I tried following syntax, syntax wise, I didn't get any error, but at the same time this opaque view is not fetch all the records as well. my session variable is 'End_date' and its value is 1998/12 / 31:00:00:00(as_shown_in_RPD_session_windows,_datatype_is_DATETIME)

    SELECT AMOUNT_SOLD, CHANNEL_ID, CUST_ID, PROD_ID, PROMO_ID, QUANTITY_SOLD, SH. SALES TIME_ID

    WHERE TIME_ID = TO_DATE (' VALUEOF (NQ_SESSION.) END_DATE) ", ' MM/DD/YYYY')"

    SELECT AMOUNT_SOLD, CHANNEL_ID, CUST_ID, PROD_ID, PROMO_ID, QUANTITY_SOLD, SH. SALES TIME_ID

    WHERE TIME_ID = TO_DATE (' VALUEOF (NQ_SESSION.) ("' END_DATE ')", ' MM/DD/YYYY') "

    SELECT AMOUNT_SOLD, CHANNEL_ID, CUST_ID, PROD_ID, PROMO_ID, QUANTITY_SOLD, SH. SALES TIME_ID

    WHEN TRUNC (TIME_ID) = TO_DATE (' VALUEOF (NQ_SESSION.) ("' END_DATE ')", ' MM/DD/YYYY') "

    In the past, I could spend a session variable in an opaque display by using the DATE filter, but which was in DB2.

    I appreciate your time and help

    Finally, I had good format. It's here

    TO_DATE (substr ("valueof (NQ_SESSION. End_date)', 1, 10), "yyyy-mm-dd")

    and here is the source where I got this information

    Using Variables in Session OBIEE in some tables of the physical layer

  • Fill the InDesign document with external data?

    Hi all, I hope that I ask this question in the correct forum. I'm assuming that it is a problem of script, but if not, I apologize. Anyway - wonder if this is possible and, if so, if someone could point me in the general direction of more information:

    My company occasionally asked to produce directories of employee containing information (photos, contact information, education information, etc.) on different segments of the population closes - for example, a directory can include all women of color, we can include everyone in the Los Angeles Office, etc.. I would like to find a way to 'model' it in InDesign so that the relevant info can circulate in the external data source document - for example, database SQL of the HR or perhaps a spreadsheet generated from this database. I know that we are currently able to do something similar by using Word, but the final product looks like crap.

    I don't know what that would be even called in InDesign, so any information will be greatly appreciated. I use the CS5 version. Thank you!

    I could do this by using the data merge feature. It is similar to the functionality of fusion and mail merge in word. There is a great video of how it works here: http://www.theindesigner.com/blog/episode-43-data-merge-video

    There are more complex ways using XML or the third party plug-ins, but I would try this method first.

    Colly

  • both sets of criteria to fill the third table of research

    Hello-

    I'm very new to the numbers and support communities. I have read help and searched this forum but could not find a similar question. I appreciate any advice or suggestions.

    I created two table of numbers of our customer base and trying to treat it as follows: (see example below)

    Objective: Create a third table, which contains the invoice number, the date, the total bill and the State of residence, owner, as long the Bill IS NOT some elements of the Bill.

    In the example below, I've composed billing YES-POINT and POINT-NO; There are real elements in the database I want to search and do not take into account these bills that contain the element ITEM-NOT all together.

    Table 1 (total of the invoice):

    The Total State owner invoice # invoice date

    1                    12/1/15         $800.00                     NC

    2                    12/2/15         $125.00                     FL

    3                    12/5/15         $300.00                     NY

    4                    12/9/15         $500.00                     CA

    Table 2: (the individual elements that make up the invoice)

    Cost of billing invoice # point

    1 POINT-YES $200.00

    1 POINT-YES $100.00

    1 POINT-YES $500.00

    ARTICLE 2 - YES $25.00

    2 POINT-NO $100.00

    ARTICLE 3 - YES $300.00

    ARTICLE 4 - YES $400.00

    4 POINT-NOT $100.00

    The table of RESULTS based on the above would look like:

    Table results:

    The Total State owner invoice # invoice date

    1                     12/1/15           $800.00                       NC

    3                     12/5/15           $300.00                       NY

    Thank you very much for your advice and guidance.

    Put Hi,

    You wrote: ""as long as the invoice DO NOT include certain billsarticle.".

    But in your example, you showed two bills containing the same "some billing."

    In practice, will you be leaving bills that contains a specific item, or will you be leaving bills that contain one or more items in a list of several items?

    Kind regards

    Barry

  • SQLLDR: How to fill the empty columns with specific data by default?

    Hello

    We are 11G

    Here is a complete example:

    (1) the definition of the table:
    create table IMPORT_PRJ_TIMESHEETS
    (
      RESSOURCE_CODE VARCHAR2(20),
      REFERENCE_DATE VARCHAR2(20),
      STATUS         VARCHAR2(20),
      PROJET_CODE    VARCHAR2(50),
      TACHE_ID       VARCHAR2(100),
      TACHE_DESC     VARCHAR2(250),
      RAF            NUMBER,
      JOUR1          NUMBER,
      JOUR2          NUMBER,
      JOUR3          NUMBER,
      JOUR4          NUMBER,
      JOUR5          NUMBER,
      JOUR6          NUMBER,
      JOUR7          NUMBER,
      IMPORT_DATE    DATE
    );
    (2) the CTL:
    LOAD DATA
    CHARACTERSET WE8ISO8859P1
       APPEND INTO TABLE IMPORT_PRJ_TIMESHEETS
    -- Pour eliminer la ligne d'en-tete
    WHEN PROJET_CODE != 'ID projet'
       FIELDS TERMINATED BY '*-*' OPTIONALLY ENCLOSED BY '"'
    ( RESSOURCE_CODE       CONSTANT '!RESSOURCE_CODE!'
    , REFERENCE_DATE       CONSTANT '!REFERENCE_DATE!'
    , STATUS               CONSTANT '!STATUS!'
    , PROJET_CODE          CHAR
    , TACHE_ID             CHAR
    , TACHE_DESC           CHAR
    , RAF                  CHAR "TO_NUMBER( :RAF, '999G999D99')"
    , JOUR1                CHAR
    , JOUR2                CHAR
    , JOUR3                CHAR
    , JOUR4                CHAR
    , JOUR5                CHAR
    , JOUR6                CHAR
    , JOUR7                CHAR
    , IMPORT_DATE          SYSDATE
    )
    {code}
    
    
    3) the datafile :
    {code}
    ID projet*-*ID tâche*-*Tâche/Description*-*RàF*-*lun. 13/07*-*mar. 14/07*-*mer. 15/07*-*jeu. 16/07*-*ven. 17/07*-*sam. 18/07*-*dim. 19/07*-*
    FR-FR-NT2300135*-* *-*GAMMAWEB - Coordination*-*0,00*-* *-* *-* *-*8,00*-*8,00*-* *-* *-*
     *-* *-*Holiday*-* *-* *-*8,00*-* *-* *-* *-* *-* *-*
     *-* *-*Special leave*-* *-*8,00*-* *-* *-* *-* *-* *-* *-*
     *-* *-*Vacation*-* *-* *-* *-*8,00*-* *-* *-* *-* *-*
    
    {code}
    
    - As you can see, the datafile delimiter is "*-*" .... there's no pb about this.
    
    - Also, there are 5 lines in the datafile. Currently, the _*load status*_ is :
       - Line 1 is the header  >>> not loaded, and that's fine with me.
       - Line 2 is successfully loaded
       - Line 3 / Line 4 / Line 5 : are not loaded .. but I need these lines ...
    
    *What I'd like to get is to successfully load lines 3 to 5 with a default values for the first 3 columns (project/task ID/ task desc)*
    
    I hope it's clear enough and that you will be able to provide a good answer ..
    
    Thanks in advance,
      Olivier                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    In your example, the only ranked with value on all lines is TACHE_DESC.
    If this field is always filled, try this:
    WHEN TACHE_DESC! = "Task/Description".

    Concerning

  • Copy the FTP files according to date and time

    Hi all

    I'm creating an application where I need to copy the last file created from a remote FTP site only. Thus, for example, if my remote/ftp location contains some folders and some files, it would list only the file that has been changed recently.

    Right now, NLST and LIST of commands give me the complete list of files and folders directly, but I don't need the file that has been recently modified.

    Can someone help me?

    Hello

    Unfortunately the LIST or the commands do not return good usable change dates and times.

    But there is an FTP task 'MDTM' command to get the date of the change of a specified file.

    You must run this command for each file individually.

    You use the FTP functions from the Internet Toolbox? Then you can do it like this:

    In the response string, you will get the response code (250 for successful operation) and the date of change.

    I think you need to find the last file with little code on the host based on the modification dates.

    Hope this helps

  • Fill the screen at a resolution high/native

    At the highest resolution (1920 x 1200, in my case), many web pages, which, only partially fill the screen... FaceBook only fills the third Center of the screen... Raise the CIO only seems to increase fonts around the borders... All boards of education seem to indicate I'm better off to native (1920 x 1200) screen resloution, but she shoots advantage of the size of my screen, and no ONE sitting with me can read the type... It is ideal for photos/videos, but not very good for reading... Any ideas on how to use the native resolution of this monitor fantasy and still have easy to use on a daily basis?

    Thank you very much
    Strabismus in Dallas

    Hello

    This does not mean that you must set the resolution all the time at the highest setting. Put it in a position that
    the best works for you. CTRL + CTRL - and CTRL mouse wheel all work as a ZOOM.

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • Update variable essbase whose date of the BONE

    Hi all

    Is it possible to update my substitution variables according to the date of the operating system? I try to avoid some of the manual processes involved in maintaining the application. I'm looking for solutions from Hyperion.

    Any help is appreciated.

    Thank you
    KK

    It's not a way to do this within the Hyperion, but it's pretty simple to write an external process (korn or bash for Unix, bat or vba for windows) to read the date system, then appropirately set a with a call from shell maxl subvar.

    Robert

  • variable sharing, missing data, the timestamp even for two consecutively given

    Hello

    I have a problem with missing data when I read a published network shared variable.

    Host VI:

    In a host of VI on my laptop (HP with Windows XP Prof.) I write data to the shared Variable 'data '. Between two consecutively write operations is a minimum milliseconds of wait time. I use it because I want to make sure that the time stamp of each new value of data is different then a preview (variables shared the resolution is 1 ms)

    VI target:

    the VI target cRIO-9012 bed only of new data in the way that it compares the timestamp of a new value with the time stamp of the last value on a device in real time.

    Problem:

    rarely, I'm missing a data point (sometimes everything works fine for several hours, transfer thousands of data correctly above all of a sudden failure occurs). With a workaround, I'm able to catch the missing data. I discovered that the missing data have the timestamp exactly the same, then the last point of data read, is so ignored in my data 'legal '.

    To summarize, the missed value is written to the variable shared host, but ignores the target because its timestamp is wrong, respectively the same as the last value, despite the host waits for a minimum of 10 milliseconds each time before writing a new value.

    Note:

    The shared Variable is hosted on the laptop and configured using buffering.

    The example is simple only to display the function of principle, in real time, I also use a handshake and I guarantee that there is no sub - positive and negative.

    Simplified example:

    Question:

    Anyone has an idea why two consecutively data can have the same timestamp?

    Where timestamping (evil) Finally comes (System?)?

    What would be a possible solution (for the moment with shared Variables)?

    -> I tried to work around the problem with the clusters where each data gets a unique ID. It works but it is slower that comparing the timestamps and I could get performance problems.

    It would change anything when I animate the shared on the RT System Variable?

    Thanks for your help

    Concerning

    Reto

    This problem has been resolved in LabVIEW 2010.  You can see other bugs corrections in theReadme of LabVIEW 2010.

  • What are the parameters? How are Variables differenet? Why we can not use variables to pass data to one sequnece to another? What is the advantage to use parameters instead of Variables?

    Hi all

    I am new to TestStand. Still in the learning process.

    What are the parameters? How are Variables differenet? Why we can not use variables to pass data to one sequnece to another? What is the advantage to use parameters instead of Variables?

    Thanks in advance,

    LaVIEWan

    I'm sorry... I discovered that... its not at all possible to pass data to another sequence using variables... it must be through settings... once again I apologize for the display of such a stupid question

Maybe you are looking for