How to remove duplicates

Alcon,

Can you please give me good suggestion how to show any record of duplicate records.

number of im get many duplicates, but I want to show a place with many, if im using ROWNUM = 1 displays a record altogether. can you give me an idea it is possble to show one.

We have three location only as ABC, BCD, JKL but we N no lot numbers...

for example. im getting output is

Does lot no location
ABC 123
123 BCD
ABC 145
JKL 145
JKL 178
ABC 178
190 BCD
ABC 190


now, I want to indicate the output below
Does lot no location
ABC 123
ABC 145
JKL 178
190 BCD

Try this

SELECT LX.LOT,MIN(L.LOCPREFIX) AS LOC
FROM      LOTXLOCXID LX,
     LOC L,
     SKU S
WHERE L.LOC=LX.LOC
AND S.SKU=LX.SKU
AND S.PVTYPE='GFM'
GROUP BY LX.LOT

The column that is used in the TEXT-TO-SPEECH function should not be used in GROUP BY for your query.

And when you are a collection, you do not need to use SEPARATE

Published by: JAC on November 20, 2012 10:31

Tags: Database

Similar Questions

  • How to remove duplicate pictures

    I imported all my photos in the photo library. How to remove duplicates of Photos (version 1.3) on OS X El Capitan without 3rd party software?

    Photos don't have a tool to detect the duplicates library. It relies on detecting when you import photos.

    If you intentionally import duplicates, you can only search for them manually, for example by sorting the photos of the capture date, if duplicates will appear side-by-side in moments.

    To search for duplicates, you need third-party software. These three are safe to use with Photos:

  • How to remove duplicate files/songs in my music library without having to click on each of them?

    original title: removal of duplicates

    How to remove duplicate files/songs in my music library without having to click on each of them?

    Hi MonicaBlanco,

    1 are. what music library you referring?

    2. did you of recent changes on the computer?

    If you are referring to the Windows media player library then the only option to remove duplicates of files is to click with the right button on the file duplicate.

    Remove items from the Windows Media Player library

    http://Windows.Microsoft.com/en-us/Windows7/remove-items-from-the-Windows-Media-Player-library

  • JS: How to remove duplicates in a table?

    JS: How to remove duplicates in a table?

    I guess there's a simple solution...

    Hey!

    Maybe something like this:

    Array.prototype.unique = function (){
        var r = new Array();
        o:for(var i = 0, n = this.length; i < n; i++){
            for(var x = 0, y = r.length; x < y; x++){
                if(r[x]==this[i]) continue o;}
            r[r.length] = this[i];}
        return r;
    }
    

    Use:

    var myArray = ["a","b","c","c","a","d","b","b"];
    alert(myArray.unique());
    

    Hope that helps.

    --

    tomaxxi

    http://indisnip.WordPress.com/

  • Photo library - iCloud how to remove duplicates

    All, someone knows something about OSX/IOS 'Photos' app will detect and remove duplicates photo9?  My library 'Photos' 63 299 photos & videos of 2135 from may 2016 and at least 10,000 + of these photos are duplicates (based on an analysis of Photosweeper). I have checked the results of the analysis of Photosweeper by doing a manual visual comparison and check images original in iphoto library (using the function location of show) and confirmed that these 10 000 + photos are images duplicate identical with names of different files in different parts of the photo library database.

    So what is happening and how to stop 10-15% of my picture library being duplicate files! I will raise this directly with the apple support payment for the 1 TB icloud service to cover my very large library 'Photos', which should probably be just a large Photo library!

    A few other comments for those who have a double problem:

    -L' old iPhoto application used to "detect duplicates" when import but the new application 'Photos' does not. Anyone know about this?

    -J' saw the documentation from apple saying the icloud search duplicates in 'Photos' when in the icloud, but clearly not work or it does not work if duplicates exist also in the version of the imac to the library 'Photos '.

    -Beware of apps that claim to find 'photos' duplicate and are recommended on various Internet sites, a number of them don't work with the old iphotos app the new application 'Photos' (I discovered after you pay and download). If you need a remover of duplicates of photos that work with 'Photos' review and stay away from any application that do not specify clearly and explicitly he works with "photos" and has been seen since the release of the Photos app.

    + I paid $10 for "Gemini" dual Finder and has been a complete waste of time that didn't work only not with the "Photos" application (it wasn't not clear documentation or support, and when I trigger it supported by Macpaw that they said gemini does not support photos and told me to buy another app macpaw - I told them to go jump in a Lake).

    + I found very good Photosweeper that you can set to match exact or variable (for example photos of accidental burst which are 99.99% identical but 0,1s collapse) and then you can right click to view original file / image in the library to manually check duplicate (if you are paranoid like me) - there are many other paid apps that also make this store then around

    Photos detects duplicates when you import pictures and when you synchronize with ICPL

    Photos does not analyse the duplicates, but checks for them during import and download of IPCL

    There are a few duplicate programs that are tested as safe with Photos, including PowerPhotos, PhotoSweeper for the pictures and Duplicate Annihilator for Photos - do not use a tested and documented as safe\

    And I'm not clear what your post is about since you are asking how to find duplicates and then provide a good answer - photoSweeper - it is one of the safe and effective ways to remove duplicates for Photos

    LN

  • How to remove duplicate rows (not exactly duplicate)

    Hi I have lines like this in a table emp

    ENO ename age
    1 25
    26 2
    3 25
    4 26

    I don't have repititve enames... (here in this example: A).

    If I find something like that I should keep the first line and delete all other lines.

    How can I do this?

    as unique empowerment of ename... (except for this)

    Hi Renon,
    There are different ways could remove duplicate rows, but Franks solution seems good.
    With the help of ID you can get good results in the largest data sets. If you want Nwe minutes remain in the database and all others to delete then make use of eno and not rowid.

    DELETE FROM emp y
    WHERE       eno != (SELECT   Min(eno)
                        FROM     emp x
                        WHERE    x.NAME = y.NAME
                        GROUP BY NAME)
    

    HTH
    SS

  • How to remove duplicates from comma separated string


    Hi all

    I have an obligation to remove duplicates of string separated by commas:

    Some examples of code (real data can be in millions)

    {code}

    create table test_dup_del (num number (10), dup_val varchar2 (100));

    insert into test_dup_del values (1234, '1, 2, 3, 4, 3, 1');
    insert into test_dup_del values (4567,'1, 2, 2, 4, 4, 1');
    insert into test_dup_del values (7894,'1, 2, 1, 3, 3, 1');
    insert into test_dup_del values (1478, '1, 2, 4, 4, 3, 2');
    insert into test_dup_del values (2589, '1, 2, 1, 2, 1, 2');
    commit;

    (code}

    my output would be:

    1234, 1, 2, 3, 4'

    4567, '1, 2, 4'

    7894, '1, 2, 3'

    1478, 1, 2, 3, 4'

    2589, 1, 2'

    Thank you

    Rachid

    If there is a real need to split the data so that it could be corrected (before split to store correctly... Tip tip!) ...

    SQL > ed
    A written file afiedt.buf

    1 with test_dup_del (num, dup_val) as)
    2 Select 1234, 1, 2, 3, 4, 3, 1' Union double all the
    3 select 4567, 1, 2, 2, 4, 4, 1' Union double all the
    4 Select 7894, 1, 2, 1, 3, 3, 1' Union double all the
    5 Select 1478, 1, 2, 4, 4, 3, 2' of all the double union
    6 select 2589, 1, 2, 1, 2, 1, 2' of the double
    7      )
    8  --
    9. end of test data
    10-
    11, split as)
    12. Select num
    13, trim (regexp_substr(dup_val,'[^,]+',1,level)) as val
    14 from test_dup_del
    15 connect by num = num prior
    16 and level<=>
    17 and prior sys_guid() is not null
    18                )
    19, dist in (select distinct)
    20                      num
    21                      ,val
    22 split
    23              )
    24 select num
    25, listagg (val, ',') within the Group (order by val) as vals
    dist 26
    27 * group by num
    SQL > /.
    NUM OF VALS
    ---------- ------------------------------
    1234 1,2,3,4
    1478 1,2,3,4
    2589 1.2
    4567 1,2,4
    7894 1,2,3

    5 selected lines.

  • How to remove duplicates in my Lightroom Catalog?

    I have merged an old Lightroom Catalog in my Lightroom hand catalogue and accidentally created duplicate images, thousands of them (sometimnes, geometry), I suppose I must have completed the process before, foregotten and not deleted catalogs I merged after that I've merged them... then go back and redo the process... thus creating duplicates.

    My problem is I want to remove duplicates without losing the edited versions. only those that I have meged in.  The file has a lot of images which is not duplicated, so I can't start the process again?

    You can remove duplicates of Lightroom is removing recognizes them in the grid view.

    However, there are a few Plugins available. Here's a Journal http://www.lightroomfanatic.com/tutorials/advanced/finding-duplicate-images-lightroom-cata /

    Find and eliminate duplicate Images in Lightroom | Lightroom training Laura shoe, tutorials and tips

    Let us know if that helps.
    Concerning

    Assani

  • How to remove duplicates of many of my images - it seems that everything I do only compooiunds the question and now I have multiples of duplicates

    tried to delete files - they just duplicate...

    tried to drag all the dups to separate the folder to remove and duplicate just once again

    Suggest that you first spread malware as the cause of the problem by following these steps:

    I. - delete your temporary files

    Click Start > all programs > Accessories > System Tools > Disk Cleanup

    II. - have your system scanned as a result of security/antivirus installed.

    III. - download, install, update, and run analyses both of these tools free anti-malware:

    MalwareBytes anti-malware (MBAM)

    http://www.Malwarebytes.org/products/malwarebytes_free>

    SUPERAntiSpyware (SAS)

    http://SUPERAntiSpyware.com/superantispywarefreevspro.html>

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_xp-files/DupFinder/ebea1df8-9a4f-4015-8E6F-3f7e8119d111>

    UTC/GMT is 00: 30 on Saturday 10 March 2012

  • How to remove duplicates in a column

    Hello

    Please find attached the sample output and I would like to delete duplicates in the column J, K, L.

    I don't see only once.

    If someone could help, how this can be achieved in BI Publisher,

    Thanks in advance a ton.

    Concerning

    Nanan

    Please let us know your model xml and rtf to this email id [email protected]

  • How to remove duplicates from the PL - SQL table?

    Hi gurus,

    I have a PL - SQL table with the following structure
    Authors (SR_NO, Auth_Code, Change_Date, cost)

    This table is filled using a slider. However, this table can have a few lines in double (for column (Auth_Code)
    for example
    SR_NO      Auth_Code       Change_Date                       Cost
    1               A1             14-FEB-09 08.18.47 AM          11.00
    2               A2             14-FEB-09 08.18.56 AM       2839.00
    3               A1             15-FEB-09 08.00.02 AM      1299.00
    4               A1             15-FEB-09 07.00.00 AM        789.00
    5               A3             14-FEB-09 08.18.56 AM        312.00
    6               A4             14-FEB-09 08.19.02 AM        233.00
    I need to get the above result set select the separate lines of Auth_Code including the Change_Date is maximum (and store in another PL - SQL table for treatment later or even the removal of this table will be also!)

    of the data A1 is duplicated and a maximum Change_Date above = 15 February 09 08.00.02 AM.
    Where my PL - SQL Table that results must have given below
    SR_NO      Auth_Code       Change_Date                       Cost
    2               A2             14-FEB-09 08.18.56 AM       2839.00
    3               A1             15-FEB-09 08.00.02 AM      1299.00
    5               A3             14-FEB-09 08.18.56 AM        312.00
    6               A4             14-FEB-09 08.19.02 AM        233.00
    I'm not very aware of the PL - SQL tables and there is no chance to change the existing cursor that fills the data in this table PL - SQL.
    I guess that I need to compare each record of PL - SQL table with others, but do not know how to do this.

    Could you please help?

    Hello

    Like this?:

    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    
    SQL>
    SQL> with data as(
      2  select 1 as SR_NO, 'A1' as Auth_Code, to_date('14-FEB-09 08.18.47', 'dd-mon-yy hh24:mi:ss') as change_date,    11.00 as cost from dual union all
      3  select 2 as SR_NO, 'A2' as Auth_Code, to_date('14-FEB-09 08.18.56', 'dd-mon-yy hh24:mi:ss') as change_date,  2839.00 as cost from dual union all
      4  select 3 as SR_NO, 'A1' as Auth_Code, to_date('15-FEB-09 08.00.02', 'dd-mon-yy hh24:mi:ss') as change_date,  1299.00 as cost from dual union all
      5  select 4 as SR_NO, 'A1' as Auth_Code, to_date('15-FEB-09 07.00.00', 'dd-mon-yy hh24:mi:ss') as change_date,   789.00 as cost from dual union all
      6  select 5 as SR_NO, 'A3' as Auth_Code, to_date('14-FEB-09 08.18.56', 'dd-mon-yy hh24:mi:ss') as change_date,   312.00 as cost from dual union all
      7  select 6 as SR_NO, 'A4' as Auth_Code, to_date('14-FEB-09 08.19.02', 'dd-mon-yy hh24:mi:ss') as change_date,   233.00 as cost from dual)
      8  select * from data d where change_date = (select max(change_date) from data d2 where d.auth_code = d2.auth_code);
    
         SR_NO AUTH_CODE CHANGE_DATE       COST
    ---------- --------- ----------- ----------
             2 A2        14/02/2009        2839
             3 A1        15/02/2009        1299
             5 A3        14/02/2009         312
             6 A4        14/02/2009         233
    
    SQL>
    

    Kind regards

  • How to remove duplicate Oracle lines and retain the last rows in double

    Hello

    I have millions of records in the table. Some values / duplicate rows are inserted into it.
    I want to just delete the duplicate lines but I also want to keep the last duplicate line.
    For example if a record is found three times, I want to delete the first and second record and keep
    the third is to say the last inserted a.


    Concerning
    Valérie Singh

    Hello

    PLS, try the commond...!

    1.
    delete from  a where rowid<(select max(rowid) from  b
    where a.ID = b.ID (or perticular column name). 
    
    OR 
    
    2.
    delete from  a where rowid>(select min(rowid) from  b
    where a.ID = b.ID (or perticular column name). 
    
    for example emp table a.empno=b.empno;
    

    * If you are satisfied with this answer make as correct
    * If you're ok withi this answer helpful also

    Concerning
    KPR

  • How to remove duplicate records...

    Hello

    I have a strange scenario below is the structure of the table

    of km
    Bangalore, Mumbai 100
    Mumbai, Bangalore 100
    Bangalore, Chennai 50

    I want the output as given that the distance is even bangalore to Bombay and mumbai to bangalore I want only one instance...

    of km
    Bangalore, Mumbai 100
    Bangalore, Chennai 50

    I was able to find duplicate using following query records but put not able to come to the final...

    Select a.frm, b.frm, a.km
    distance a distance b
    where a.frm = b.too
    and b.frm = a.too

    Thanks in advance...


    Sree
    WITH t AS (
                SELECT 'Bangalore' col1, 'Mumbai' col2, 100 col3 FROM DUAL
               UNION ALL
                SELECT 'Mumbai', 'Bangalore', 100 FROM DUAL
               UNION ALL
                SELECT 'Bangalore', 'Chennai', 50 FROM DUAL
              )
    SELECT  DISTINCT LEAST(col1,col2) col1,
                     GREATEST(col1,col2) col1,
                     col3
      FROM  t
    /
    
    COL1      COL1            COL3
    --------- --------- ----------
    Bangalore Mumbai           100
    Bangalore Chennai           50
    
    SQL> 
    

    SY.

  • How to remove duplicates from a Table using PL/SQL

    I created the following tables with data:

    * Table 1: *.



    Department of CREATE TABLE

    (DEPARTMENT_ID 4 NUMBER PRIMARY KEY,

    DEPARTMENT_NAME VARCHAR2 (20).

    ADDRESS VARCHAR2 (20));







    INSERT INTO Department VALUES (10, 'ACCOUNTING', 'NEW YORK');

    INSERT INTO Department VALUES (20, "SEARCH", "DALLAS");

    INSERT INTO Department VALUES (30, 'SALES', 'CHICAGO');

    INSERT INTO Department VALUES (40, 'OPERATIONS', 'BOSTON');

    COMMIT;



    * 2nd table: *.

    CREATE TABLE employee

    (EMPLOYEE_ID NUMBER 4 PRIMARY KEY,

    EMPLOYEE_NAME VARCHAR2 (20).

    USE VARCHAR2 (20).

    MANAGER_ID NUMBER 4,

    HIRE_DATE DATE,

    NUMBER OF SALARY (9, 2)

    COMMISSION (9, 2) NUMBER,

    Department_id number 4 REFERENCES department (DEPARTMENT_ID));






    INSERT INTO employee

    VALUES (7839, 'KING', 'PRESIDENT', NULL, NOVEMBER 17, 81 ', 5000, NULL, 10);

    INSERT INTO employee

    VALUES (7698, "BLAKE", "MANAGER", 7839, MAY 1, 81 ', 2850, NULL, 30);

    INSERT INTO employee

    VALUES (7782, "CLARK", "MANAGER", 7839, JUNE 9, 81 ', 2450, NULL, 10);

    INSERT INTO employee

    VALUES (7566, "JONES", "MANAGER", 7839, APRIL 2, 81 ', 2975, NULL, 20);

    INSERT INTO employee

    VALUES (7654, 'MARTIN', 'SELLER', 7698, 28-SEP-81', 1250, 1400, 30);

    INSERT INTO employee

    VALUES (7499, 'ALLEN', 'SELLER', 7698, FEBRUARY 20, 81 ', 1600, 300, 30);

    INSERT INTO employee

    VALUES (7844, 'TURNER', 'SELLER', 7698, ' 08-SEP-81', 1500, NULL, 30);

    INSERT INTO employee

    VALUES (7900, 'JAMES', 'CLERKS', 7698, 3 DECEMBER 81', 950, NULL, 30);

    INSERT INTO employee

    VALUES (7521, 'WARD', 'SELLER', 7698, FEBRUARY 22, 81 ', 1 250, 500, 30);

    INSERT INTO employee

    VALUES (7902, "FORD", "ANALYST", 7566, DECEMBER 3, 81 ', 3000, NULL, 20);

    INSERT INTO employee

    VALUES (7369, 'SMITH', 'CLERKS', 7902, DECEMBER 17, 81 ', 800, NULL, 20);

    INSERT INTO employee

    VALUES (7788, 'SCOTT', 'ANALYST', 7566, DECEMBER 9, 82 ', 3000, NULL, 20);

    INSERT INTO employee

    VALUES (7876, ' ADAMS, "CLERK", 7788, 12 JANUARY, 83', 1100, NULL, 20);

    INSERT INTO employee

    VALUES (7934, 'MILLER', 'CLERKS', 7782, JANUARY 22, 82 ', 1300, NULL, 10);

    COMMIT;



    I need to print all Department names, employee and salary. I did this, but how can display the name of each Department only once?





    Here is my code:



    DECLARE

    v_department_name department.department_name%TYPE;

    v_employee_name employee.employee_name%TYPE;

    v_salary employee.salary%TYPE;

    CURSOR dept_cur

    IS

    SELECT employee_name, department_name, Department OF employee salary

    WHERE department.department_id = employee.department_id (+)

    ORDER BY department_name, employee_name;

    BEGIN

    OPEN dept_cur.

    EXTRACT the dept_cur IN v_department_name, v_employee_name, v_salary;

    DBMS_OUTPUT. PUT_LINE ('DEPARTMENT_NAME EMPLOYEE_NAME WAGES');

    DBMS_OUTPUT. PUT_LINE('---------------------------------------------------');

    While dept_cur % FOUND

    LOOP

    DBMS_OUTPUT. Put_line (RPAD (v_department_name, 10) |) ' ' || RPAD (v_employee_name, 10). ' ' || v_salary);

    EXTRACT the dept_cur IN v_department_name, v_employee_name, v_salary;

    END LOOP;

    CLOSE Dept_cur;

    END;

    I would appreciate if you could help me with this. I'm sure it's a quick and easy answer, but I can't do it. I spent so much time already.

    Published by: 831522 on January 26, 2011 11:44

    It is a problem of display/reports rather than a problem of duplication of query data. The answer depends on what tools you use to query and display the data. You can use the clause "break it" I suggested earlier if you use SQL Plus.

    Otherwise, you can try this based on the version of Oracle you are using. Someone else may be able to get the data in a single pass.

    SELECT decode(emp_id, 1, department_name) department_name, employee_name, salary
    FROM(SELECT department_name, employee_name, salary,
           ROW_NUMBER() OVER (PARTITION BY department_name order by department_name, employee_name) AS emp_id
         FROM department
         LEFT OUTER JOIN employee ON (department.department_id = employee.department_id)
    ORDER BY department_name, employee_name, emp_id);
    
  • How to remove duplicates in two separate lines in SQL?

    Hello

    I need to identify the data in double with two separate lines. See my below data structure.
    INDEX OF NAMES NAME_1 START_DATE END_DATE FLAG VALUE
    B ON 275 SE 13/12/2005-31/12/2010 1
    SELF 1 375
    SELF 1 475
    ON 275 SE 2 B 13/12/2005-31/12/2010
    SELF 2 375
    SELF 2 475
    ON SE 175 13/12/2006 AND 31/12/2010 B 3
    SELF 3 375
    SE ON 3 475

    This is my sample data. Here, the data is mirrored with different index columns. INDEX 1 and 2 contains the same combination group. I so need to identify one of the combination double (i.e. INDEX 1 or 2). Anyone can come up with the exact solution?

    Thank you

    I thought it had to do with the order of the INDEX field. The query checks only the value of the previous INDEX value.

    I think I found what the problem was.

    Try this:

    with test_table as
    (select 'SUR' NAME, 'SE' NAME_1, '275' VALUE, to_date('13/12/2005','DD/MM/YYYY') START_DATE, to_date('31/12/2010','DD/MM/YYYY') END_DATE, 'B' FLAG, 1 IND from dual union all
    select 'SUR', 'SE', '375', null, null, 'A', 1 from dual union all
    select 'SUR', 'SE', '475', null, null, 'A', 1 from dual union all
    select 'SUR', 'SE', '275', to_date('13/12/2005','DD/MM/YYYY') ,to_date('31/12/2010','DD/MM/YYYY') ,'B', 2 from dual union all
    select 'SUR', 'SE', '375', null, null, 'A', 2 from dual union all
    select 'SUR', 'SE', '475', null, null, 'A', 2 from dual union all
    select 'SUR', 'SE', '175', to_date('13/12/2006','DD/MM/YYYY'), to_date('31/12/2010','DD/MM/YYYY'), 'B', 3 from dual union all
    select 'SUR', 'SE', '375', null, null, 'A', 3 from dual union all
    select 'SUR', 'SE', '475', null, null, 'A', 3 from dual union all
    select 'SUR', 'SE', 'IPT', to_date('13/12/2005','DD/MM/YYYY'), to_date('31/12/2010','DD/MM/YYYY'), 'B', 100 from dual union all
    select 'SUR', 'SE', '375',null, null, 'A', 100 from dual union all
    select 'SUR', 'SE', 'AO', null, null, 'A', 100 from dual union all
    select 'SUR', 'SE', 'IPT', to_date('13/12/2005','DD/MM/YYYY'), to_date('31/12/2010','DD/MM/YYYY'), 'B', 218 from dual union all
    select 'SUR', 'SE', '375' ,null, null,'A' ,218 from dual union all
    select 'SUR', 'SE', 'AM' ,null, null,'A' ,218 from dual union all
    select 'SUR', 'SE', 'IPT' , to_date('13/12/2005','DD/MM/YYYY'), to_date('31/12/2008','DD/MM/YYYY'), 'B', 334 from dual union all
    select 'SUR', 'SE', '375' ,null, null,'A', 334 from dual union all
    select 'SUR', 'SE', 'AP',null, null, 'A', 334 from dual union all
    select 'SUR', 'SE', 'IPT' , to_date('01/01/2009','DD/MM/YYYY'), to_date('31/12/2010','DD/MM/YYYY'), 'B', 335 from dual union all
    select 'SUR', 'SE', '375' ,null, null,'A', 335 from dual union all
    select 'SUR', 'SE', 'AP',null, null, 'A', 335 from dual union all
    select 'SUR', 'SE', 'IPT' , to_date('13/12/2005','DD/MM/YYYY'), to_date('31/12/2010','DD/MM/YYYY'), 'B', 336 from dual union all
    select 'SUR', 'SE', '375' ,null, null,'A', 336 from dual union all
    select 'SUR', 'SE', 'AP',null, null, 'A', 336 from dual)
    SELECT name,
           name_1,
           value,
           start_date,
           end_date,
           flag,
           ind,
           MIN(diff_flag) over(PARTITION BY NAME, NAME_1, IND) min_flag
      FROM (SELECT t3.*,
                   CASE
                     WHEN lag(VALUE, lag_flag)OVER(ORDER BY IND, start_date, VALUE) != VALUE AND flag = 'A' THEN
                      1
                     WHEN (lag(value, lag_flag)OVER(ORDER BY IND, start_date, VALUE) != value
                        OR lag(start_date, lag_flag) OVER(ORDER BY IND, start_date, VALUE) != start_date
                        OR lag(end_date, lag_flag) OVER(ORDER BY IND, start_date, VALUE) != end_date)
                        AND flag = 'B' THEN
                      1
                     WHEN lag_flag = 0 THEN
                      1
                     ELSE
                      2
                     END diff_flag
              FROM (SELECT t2.*,
                           first_value(lag_count_flag) OVER(PARTITION BY NAME, NAME_1, IND
                                                                ORDER BY NAME, NAME_1, start_date) lag_flag
                      FROM (SELECT t1.*,
                                   CASE
                                     WHEN FLAG = 'B' THEN
                                      lag(COUNT, 1, 0)
                                      OVER(ORDER BY IND, start_date, VALUE)
                                   END lag_count_flag
                              FROM (SELECT t.*,
                                           COUNT(*) over(PARTITION BY NAME, NAME_1, IND) COUNT,
                                           row_number() over(PARTITION BY NAME, NAME_1, VALUE,
                                                                          START_DATE, END_DATE, FLAG
                                                                 ORDER BY IND) row_number
                                      FROM test_table t) t1) t2) t3) t4
     ORDER BY ind,
              start_date,
              VALUE;
    

    Published by: Manuel Vidigal on Abr 13, 2009 18:18

Maybe you are looking for

  • Problem with the game on XP XP3

    I ran into this problem on my XP computer. I know, I know. Old school freak who has not made a change for Vista... closing. In any case, I'm having a problem with the compatibility of the SP3 with a SP2 game, otherwise known as Grand Theft Auto San A

  • The hard drive works for 1/2 hour at the start before I can use the computer.

    I tried all the registry cleaners, etc. with nothing doesn't. Is there a way to know what is happening during this time?I use AVG virus and tweak.now for other things.

  • filter third-party applications

    Hi all I need to list the third-party Applications installed on the device. I tried to use CodeModuleManager, but it is all module handles. Is there a way to filter the applications? any help is appreciated... Concerning

  • reset the original spec desktop grid

    I'm unable to the resolution.  The specifications of the grid that indicates the spacing between icons on the desktop when automatically aligned doubled twice.  How can I get the specification to the original?  I have to DESACT automatic alignment an

  • set to manual 12 c level encounter error: Message of the o/s: no child processes

    HelloI'm reclassification of 11.2.0.2 to 12.1.0.2 on Solaris Oracle database.I chose the manual option rather than using DBUA.I've updated ORACLE_SID / PATH / ORACLE_HOME / setting of the ORATTAB to reflect the new 12.  Ran also alert and script erro