How to compare the unique column values

Hi all

I have data in following manner

PAT_ID PAT_ENC_CSN_ID DEPT_ID EFFECTIVE_DATE

Z369160557291136405500122 APRIL 14
Z369160557291136405500222 APRIL 14
Z269466457982980405500116 MAY 14
Z269466457982980405500216 MAY 14
Z268924357987777405500116 MAY 14
Z268924357987777405500218 MAY 14

My requirement is to know if the patient changes in another Department at the same time, so I need to select the patient or even dismiss the patient. In my example above, I have to select Z3691605 and Z2694664 patients and ignore the remaining patient.

Can someone plase help me with the code for that sql. I use 11g.

Hope I have my question clearly.

Thank you.

Here is a way use are:

SQL > select *.

2 t a

3 where exists (select 1

4t b

5 where a.pat_id = b.pat_id

6 and a.pat_enc_csn_id = b.pat_enc_csn_id

7 and a.effective_date = b.effective_date

8 and a.dept_id <> b.dept_id

9                );

PAT_ID PAT_ENC_CSN_ID DEPT_ID EFFECTIVE_DATE

------------------------------ -------------------- -------------------- --------------------

Z3691605 57291136 4055002 22 APRIL 2014 00:00:00

Z3691605 57291136 4055001 22 APRIL 2014 00:00:00

Z2694664 57982980 4055002 16 MAY 2014 00:00:00

Z2694664 57982980 4055001 16 MAY 2014 00:00:00

Tags: Database

Similar Questions

  • How to display the database column value in a component of choice selected?

    Hello everyone;

    I use Jdeveloper 11.1.1.4 and right now I have the .jspx UI page that includes < af:selectonechoice / > components and according to the requirment I have to fill one of the column in the table in this drop-down list.

    can someone tell me how to fill the database column value in this drop-down list. I know I need to create the VO for the same thing, but I'm new to this technology. Then please suggest.

    Thanks in advance.,

    This will help u

    https://blogs.Oracle.com/prajkumar/entry/create_lov_in_adf_application

    How to create LOV in ADF 11 g | Techartifact

    Oracle Fusion Middleware Technologies: 11G: how to create a list of Values (LOV)?

    http://www.baigzeeshan.com/2010/03/creating-lov-in-ADF-application.html

    http://husaindalal.blogspot.de/2010/05/How-to-default-lov-with-its-first-value.html

  • How to put the two column values in two different colors unique online: MobApp

    Hello

    I develop Mobile Application.
    I want to show two values in different columns in single row and first column value in either green or red and the second color the default column value.
    the first value of the column is green when the value is greater than the second value of the column.
    and the first column value in red when the value is less than the second value of the column.
    The code I tried is:
    --------------------------------------------------------------------------------------------
    < tr:panelGroupLayout layout = "vertical" styleClass = 'list' >
    < tr:panelList styleClass = "panelist ul > li > a" >


    "" < tr:outputText value = "deliver: % #{row.bindings.OccCurr.inputValue},
    inlineStyle = "background-color: #{rank." OccCurr > line. OccFcst? {'Green': 'Red'}; ">

    "< tr:outputText value =" OccFcst: #{row.bindings.OccFcst.inputValue} % ">"

    < / tr:outputText >
    < / tr:outputText >
    < / tr:panelList >
    < / tr:panelGroupLayout >
    ------------------------------------------------------------------------------------------------

    But the code above does not work.


    Please, someone tell me what I need to do.


    I apreciate your time and your help.

    Sanchez.

    Hi Catherine,

    Exactly, what is not working? Your OccCurr and OccFcst values are printed to the screen? I notice some questions.

    (1) If you want to display two outputText on one line, you can surround them with a panelGroupLayout and set the page layout to horizontal.
    (2) I don't think that you can place an outputText in outputText one another as in the codes that you have provided.
    (3) your EL is inconsistent. What is #{row.bindings.OccCurr.inputValue} or #{line. OccCurr}? If your values are displayed, but the background color does not work, it could be the first.

    
      
        
          
          
        
      
    
    

    Kind regards
    Amélie Chan

  • Transpose the unique column values online

    Hi all

    How to transpose the values of one column in a row,

    COL

    1

    2

    3

    4

    5

    6

    7

    8

    and I want to convert this column into the line as follows:

    Line (each in a separate column value). Number of values is not constant.

    1,2,3,4,5,6,7,8

    Solution without converting them to XML:

    WITH row_values

    AS (SELECT DISTINCT property_name,

    column_order

    OF v_rd_property_definition

    WHERE lp_id = 5171

    ORDER BY column_order)

    SELECT Regexp_substr(Wm_concat(property_name), "[^,] +' 1, 1") AS col1,.

    Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 2"). AS col2.

    Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 3") AS col3.

    Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 4") AS col4,.

    Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 5") AS col5,.

    Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 6") AS col6,.

    Regexp_substr (Wm_concat(property_name), "[^,] +' 1, 7") AS col7

    OF row_values;

  • kindly tell how to use the unique value of a table with the index 0

    kindly tell how to use the unique value of a table with the index 0

    Hi
     
    Yep, use Index Array as Gerd says. Also, using the context help ( + h) and looking through the array palette will help you get an understanding of what each VI does.
     
    This is fundamental LabVIEW stuff, perhaps you'd be better spending some time going through the basics.
     
    -CC
  • How to compare the new values with the old values in triggers.

    Dear all,

    Please tell me how to compare the new values with the old values in triggers.

    Hi, the employee example is in the document. You'd better read yourself.

    CREATE OR REPLACE TRIGGER Print_salary_changes
      BEFORE DELETE OR INSERT OR UPDATE ON Emp_tab
      FOR EACH ROW
    WHEN (new.Empno > 0)
    DECLARE
        sal_diff number;
    BEGIN
        sal_diff  := :new.sal  - :old.sal;
        dbms_output.put('Old salary: ' || :old.sal);
        dbms_output.put('  New salary: ' || :new.sal);
        dbms_output.put_line('  Difference ' || sal_diff);
    END;
    /
    
  • How to compare the 2 versions of the same document in Pages?

    How to compare the 2 versions of the same document on Pages?

    There is no OS X Visual tool which can open two Pages document and show the differences between them - other than the human eye.

    What information are you interested in identify as different between the two documents? What specific version of Pages?

  • How to put the 2nd column 1st column in excel

    Hello

    I have a question how to set the 2nd column 1st column in excel. Thank you.

    Why the 1 iteration for loops?

    Why two Index tables?  He's just trying to solve the problem created by the loops For on the original 1 d arrays.

    Two of these things create 2D tables which are what complicates things and can be eliminated.

    You can take your 2 1 d tables, use build table and right-click to set 'concatenate the inputs.

    If you have a 2D array, you can use table remodel to make a 1 column of the table of N line 2D.

  • How to read the two columns of data from the Port series

    Hello

    I'm reading two columns of data from the serial port.

    Example:

    52439 52430

    52440 52437

    52209 52214

    51065 51070

    52206 52390

    I use the serial of Visa service and I can read the first column of data from the serial port, but I can't understand how to read the second column.

    I want to both sets of chart data.

    I enclose my VI.

    Thank you for your help.

    The analysis of string function takes a "Format string" on top (with the right button of the function and choose Help, which explains all the entries).  In particular, you can say 'Give me two numbers separated by a tab' and the output will be two numbers (whole or floating, depending on the chosen format).  In particular, %d\t%d specifies a decimal integer, , whole decimal.

  • How to compare the content of two Wordpad / documents notebook without reading them line by line?

    How to compare the content of two Wordpad / documents notebook without reading them line by line?

    Hello

    Without this feature is included in the operating system.

    However, you can use your favorite search engine to look for software that needs to perform these tasks.

    WARNING of THIRD PARTY SOFTWARE: Using third-party software, including hardware drivers can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the use of third-party software can be solved. Software using third party is at your own risk.

    Hope this information helps.

  • Columns of folder: by default, how can return the first column 'Name' without having to move it manually every time?

    Something's happened awhile and when I create a folder which appears the first column is the column 'Date modified '. By default, how can return the first column 'Name' without having to move it manually every time?

    Hello

    I suggest you to visit these links and check if it helps:

    http://Windows.Microsoft.com/en-us/Windows-Vista/working-with-files-and-folders#section_4

    http://Windows.Microsoft.com/en-us/Windows-Vista/folders-frequently-asked-questions

    It will be useful.

  • How to display the comments column in Windows Media Player 12?

    WMP12 - how to display the comments column?

    I want to see the Cooments ColonneB in my WMP ads, but it is not giving me the option.

    Hello

    1. What do you mean exactly by the column comments?
    2. are you referring to in Windows Media Player?

    If you want to change the information contained in the Windows Media Player, you can follow the steps in this article.

    http://Windows.Microsoft.com/en-us/Windows7/add-or-edit-media-information-in-Windows-Media-Player

  • How to change the number of values in the hour that are restricted.

    Hello

    May I know how to change the number of values in the hour that are restricted.

    In fact, we have improved of obiee in obiee 11g 10g. Data base is the same for Both.In 10 g the prompt value is limited to show only 35 records per page. As we passed it shows only 35 Records in 11g also. How can I change this limit to 11g.

    Please suggest me! Its urgent!

    Thanks and greetings

    Navnitha

    Hello

    In the advance tab we have the XML of the upgraded report, copy it into a Notepad and try to find the line beginning as below

    In 10g, we have something like below, simply remove the choicesPerPage = '35' from 11 g OBIEE XML report

    Thank you

    RAM

  • How to add the new column in existing table to our desired location?

    How to add the new column in existing table to our desired location?

    For example, I have to add the new column 'course' before the salary column in the emp table.

    I think the best way is to add the column at the end of the table and create a new view with the order of the columns...

    Another option...

    places the data into a temporary table and recreate the table with the correct order of the columns, and then insert data to the table from the temporary table

    Refer

    Add column (from table) in the desired position

    Example:

    CREATE TABLE temp_my_user LIKE)

    SELECT * FROM password);

    DROP TABLE password;

    (Password) CREATE TABLE

    userID NUMBER

    , first name VARCAHR2 (25)

    , middleInitial VARCHAR2 (1)

    (, name VARCHAR2 (25));

    INSERT INTO password (userID, firstName, lastName)

    (SELECT username

    first name

    lastName

    OF temp_my_user);

    DROP TABLE temp_user;

  • HOW TO COMPARE THE REGULAR TEACHER VS VERSIONS?

    HOW TO COMPARE THE REGULAR TEACHER VS VERSIONS?

    Thank you

    An educational version of Photoshop Elements are totally same (feature wise) than the regular commercial versions. So, it is unnecessary to compare.

Maybe you are looking for

  • Training view app on Apple Watch

    After upgrading to 2.2.2 this week I noticed the display of training last app is zoomed and off center.  I tried to turn on and off on the watch and iPhone zoom feature, but no luck.  Here are the screenshots of the problem.  The countdown screen was

  • Firefox 4 b 2 and Windows 7, several tabs appears as a Windows OS-taskbar

    I have been using Firefox on my computer Windows 7 basic (x 64 Ultimate) and I didn't have this experience when you use v3.6 and earlier versions. But since I updated to v4 (beta 1 and now beta 2), I noticed that when I have several tabs open in Fire

  • Options to Hibernate and sleep Portege R600 No. after fresh XP install?

    I just installed a new XP and it seems that windows is not able to Hibernate or Stand By. When I click to "Turn off computer" in the menu start, the menu offers me just close and restart. Stand is unavalable (in grey) and hibernation is not yet liste

  • Tecra S1: OS cannot recognize the CD Rom after hibernation or standby

    Hello worldI have a problem with my laptop Tecra S1 and the operating system Windows XP Professional. My laptop can not recognize the CD ROM drive after hibernation modes or in sleep. And when I checked the status of the device, he told me this messa

  • Off accidentally part of details of the folder window.

    I turned off accidentally in the details box in the windows folder.  You know, the part with the parameters of image and glimpse small properties that is at the bottom of a window folder.  I tried the accitions provided in Windows Help and Support, b