Find duplicate records withouyqusing group by and having

I know i can delete duplicate records using an analytic function. I don't want to delete the records, I want to look at the data to try to understand why I have duplicates. I am looking at tables that don't have unique constraints (I can't do anything about it). I have some very large tables. so I am trying to find a faster way to do this.
for example
myTable
col1 number,
col2 number,
col3 number,
col4 number,
col5 number)
My key column is col1 and col2 (it is not enforced in the database). So I want to get all the records that have duplicates on these fields and put them in a table to review. This is a standard way to do it, but it requires 2 full table scans of very large tables (many, many gigabtytes. one is 150 gbs and not partitioned), a sort, and a hash join. Even if i increase sort_area_size and hash_area_size, it takes a long time to run..
create table mydup
as
select b.*
from (select col1,col2,count(*)
from myTable
group by col1, col2
having count(*) > 1) a,
myTable b
where a.col1 = b.col1
and a.col2 = b.col2
I think there is a way to do this without a join by using rank, dense_rank, or row_number or some other way. When I google this all I get is how to "delete them". I want to analyze them a nd not delete them.

create table mytable (col1 number,col2 number,col3 number,col4 number,col5 number);
insert into mytable values (1,2,3,4,5);
insert into mytable values (2,2,3,4,5);
insert into mytable values (3,2,3,4,5);
insert into mytable values (2,2,3,4,5);
insert into mytable values (1,2,3,4,5);
SQL> ed
Wrote file afiedt.buf
  1  select * from mytable
  2   where rowid in
  3  (select rid
  4      from
  5     (select rowid rid,
  6              row_number() over
  7              (partition by
  8                   col1,col2
  9               order by rowid) rn
10          from mytable
11      )
12    where rn <> 1
13* )
SQL> /
      COL1       COL2       COL3       COL4       COL5
         1          2          3          4          5
         2          2          3          4          5
SQL>Regards
Girish Sharma

Similar Messages

  • Help with Finding Duplicate records Query

    HI,
    I am trying to write a query that will find duplicate records/cases.
    This query will be used in a report.
    So, here are the requirements:
    I need to find duplicate cases/records based on the following fields:
    DOB, DOCKET, SENT_DATEI was able to do that with the following query. The query below is able to give me all duplicate records based on the Criteria above
    SELECT      DEF.BIRTH_DATE DOB,
               S.DOCKET DOCKET,
               S.SENT_VIO_DATE SENT_DATE, COUNT(*)
    FROM SENTENCES S,
                DEFENDANTS DEF
    WHERE      S.DEF_ID = DEF.DEF_ID
    AND       S.CASE_TYPE_CODE = 10
    GROUP BY  DEF.BIRTH_DATE, S.DOCKET, S.SENT_VIO_DATE
    HAVING COUNT(*) > 1;
    //I AM GOING TO CALL THIS QUERY 'X'Now, the information to be displayed on the report: defendants Name, DOB, District, Docket, Def Num, Sent Date, and PACTS Num if possible.
    The problem that I need help on is how to combine those queries together (what I mean is a sub query). the 'X' query returns multiple values. please have a look at the comments on the query below to see what I'm trying to achieve.
    here is the main query:
    SELECT      INITCAP(DEF.LAST_NAME) || ' ' || INITCAP(DEF.FIRST_NAME) || ' ' || INITCAP(DEF.MIDDLE_NAME) DEFENDANT_NAME,
            DEF.BIRTH_DATE DOB,
            TRIM(DIST.DISTRICT_NAME) DISTRICT_NAME,
            S.DOCKET DOCKET,
            S.DEF_NUM DEF_NUM,
            S.SENT_VIO_DATE SENT_DATE,
            DEF.PACTS_ID PACTS_NUM
    FROM      USSC_CASES.DEFENDANTS DEF,
            USSC_CASES.SENTENCES S,
            LOOKUP.DISTRICTS DIST
    WHERE      DEF.DEF_ID = S.DEF_ID
    AND      S.DIST_ID = DIST.USSC_DISTRICT_ID
    AND     S.CASE_TYPE_CODE = 10
    AND     S.USSC_ID IS NOT NULL
    AND // what i'm trying to do is: DOB, DOCKET, SENT_DATE IN ('X' QUERY), is this possible ??
    ORDER BY DEFENDANT_NAME; thanks in advance.
    I am using Oracle 11g, and sql developer.
    if my approach doesn't work, is there a better approach ?
    Edited by: Rooney on Jul 11, 2012 3:50 PM

    If I got it right, you want to join table USSC_CASES.DEFENDANTS to duplicate rows in USSC_CASES. If so:
    SELECT  INITCAP(DEF.LAST_NAME) || ' ' || INITCAP(DEF.FIRST_NAME) || ' ' || INITCAP(DEF.MIDDLE_NAME) DEFENDANT_NAME,
            DEF.BIRTH_DATE DOB,
            TRIM(DIST.DISTRICT_NAME) DISTRICT_NAME,
            S.DOCKET DOCKET,
            S.DEF_NUM DEF_NUM,
            S.SENT_VIO_DATE SENT_DATE,
            DEF.PACTS_ID PACTS_NUM
      FROM  USSC_CASES.DEFENDANTS DEF,
             SELECT  *
               FROM  (
                      SELECT  S.*,
                              COUNT(*) OVER(PARTITION BY DEF.BIRTH_DATE, S.DOCKET, S.SENT_VIO_DATE) CNT
                        FROM  USSC_CASES.SENTENCES S
               WHERE CNT > 1
            ) S,
            LOOKUP.DISTRICTS DIST
      WHERE DEF.DEF_ID = S.DEF_ID
       AND  S.DIST_ID = DIST.USSC_DISTRICT_ID
       AND  S.CASE_TYPE_CODE = 10
       AND  S.USSC_ID IS NOT NULL
      ORDER BY DEFENDANT_NAME;If you want to exclude duplicates from the query and do not care which row out of duplicate rows to choose:
    SELECT  INITCAP(DEF.LAST_NAME) || ' ' || INITCAP(DEF.FIRST_NAME) || ' ' || INITCAP(DEF.MIDDLE_NAME) DEFENDANT_NAME,
            DEF.BIRTH_DATE DOB,
            TRIM(DIST.DISTRICT_NAME) DISTRICT_NAME,
            S.DOCKET DOCKET,
            S.DEF_NUM DEF_NUM,
            S.SENT_VIO_DATE SENT_DATE,
            DEF.PACTS_ID PACTS_NUM
      FROM  USSC_CASES.DEFENDANTS DEF,
             SELECT  *
               FROM  (
                      SELECT  S.*,
                              ROW_NUMBER() OVER(PARTITION BY DEF.BIRTH_DATE, S.DOCKET, S.SENT_VIO_DATE ORDER BY 1) RN
                        FROM  USSC_CASES.SENTENCES S
               WHERE RN = 1
            ) S,
            LOOKUP.DISTRICTS DIST
      WHERE DEF.DEF_ID = S.DEF_ID
       AND  S.DIST_ID = DIST.USSC_DISTRICT_ID
       AND  S.CASE_TYPE_CODE = 10
       AND  S.USSC_ID IS NOT NULL
      ORDER BY DEFENDANT_NAME;SY.

  • How to create an activity when system finds duplicate record!!

    Hi CRM Experts,
    I am working on CRM 5.0. We are uploading contact details to CRM through ELM.
    Here My queries are:
    1) How to create An Activity when system finds duplicate record?
    2) By using ELM we can create BP with Activities and BP with Leads. But Here, my scenario is we have to Create BP with leads and Acivities. can any one help me on these areas?
    Thank in Advance.
    Sree

    Hi Sree,
    I can help you with your first query.
    When the system finds a duplicate record then either the system stops working further or proceeds with the error free record.
    So once the duplicate entry is found only the first record will be considered and not the second or the duplicate record.
    Regards,
    Rekha Dadwal
    Kindly reward with points if usefull !!!!

  • Group by and having

    Hi,
    According to standard sql, we must have:
    select ___
    from ___
    where ___
    group by ___
    having ___;
    However, I tried do the query with the following order:
    select ___
    from ___
    where ___
    having ___
    group by ___;
    And I received the same result.
    Does anybody knows the difference between those two orders? Are they always give the same result?
    Thank You

    According to the 9i documentation:
    Specify GROUP BY and HAVING after the where_clause and CONNECT BY clause. If you specify both GROUP BY and HAVING, they can appear in either order.
    Which you've got to admit does match your experience.
    Cheers, APC

  • GROUP BY and HAVING can appear in either order.

    Hi,
    please give me one example for the following line i found it in "19-28 Oracle Database SQL Language Reference".
    If you specify both GROUP BY and HAVING, then they can appear in
    either order.
    yours sincerly

    Hi,
    944768 wrote:
    that means both queries bring same result?Right; both ways produce the same results.
    GROUP BY  deptno
    HAVING    COUNT (*) > 2does exactly the same thing, just as efficiently as
    HAVING    COUNT (*) > 2
    GROUP BY  deptno

  • Use of group by and having clause

    hi frnds
    can anybody explain me the use of group by an having clause in select state ment

    Hi Rohit,
    1. GROUP BY f1 ... fn
    2. GROUP BY (itab)
    1. GROUP BY f1 ... fn
    Effect
    Groups database table data in a SELECT command on one line in the result set. A group is a set of lines which all have the same values in each column determined by the field descriptors f1 ... fn.
    ... GROUP BY f1 ... fn always requires a list in the SELECT clause. If you use field descriptors without an aggregate funciton in the SELECT clause, you must list them in the GROUP BY f1 ... fn clause.
    Example
    Output the number of passengers, the total weight and the average weight of luggage for all Lufthansa flights on 28.02.1995:
    TABLES SBOOK.
    DATA:  COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
    DATA:  CONNID LIKE SBOOK-CONNID.
    SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
           INTO (CONNID, COUNT, SUM, AVG)
           FROM SBOOK
           WHERE
             CARRID   = 'LH'       AND
             FLDATE   = '19950228'
           GROUP BY CONNID.
      WRITE: / CONNID, COUNT, SUM, AVG.
    ENDSELECT.
    Note
    ... GROUP BY f1 ... fn is not supported for pooled and cluster tables.
    2. GROUP BY (itab)
    Effect
    Works like GROUP BY f1 ... fn if the internal table itab contains the list f1 ... fn as ABAP source code. The internal table itab can only have one field. This field must be of the type C and should not be more than 72 characters long. itab must be enclosed in parentheses and there should be no blanks between the parentheses and the table name.
    Note
    The same restrictions apply to this variant as to GROUP BY f1 ... fn.
    Example
    Output all Lufthansa departure points with the number of destinations:
    TABLES: SPFLI.
    DATA:   BEGIN OF WA.
              INCLUDE STRUCTURE SPFLI.
    DATA:     COUNT TYPE I.
    DATA:   END OF WA.
    DATA:   WA_TAB(72) TYPE C,
            GTAB LIKE TABLE OF WA_TAB,
            FTAB LIKE TABLE OF WA_TAB,
            COUNT TYPE I.
    CLEAR: GTAB, FTAB.
    WA_TAB = 'COTYFROM COUNT( * ) AS COUNT'. APPEND FTAB.
    APPEND WA_TAB TO FTAB.
    WA_TAB = 'CITYFROM'.
    APPEND WA_TAB TO GTAB.
    SELECT DISTINCT (FTAB)
           INTO CORRESPONDING FIELDS OF WA
           FROM SPFLI
           WHERE
             CARRID   = 'LH'
           GROUP BY (GTAB).
      WRITE: / WA-CITYFROM, WA-COUNT.
    ENDSELECT.
    Regards,
    Susmitha

  • Question about GROUP BY and HAVING

    Good afternoon,
    I have the following query which returns the desired result (set of students who take CS112 or CS114 but not both). I wanted to "condense" it into a single SELECT statement (if that is at all possible - DDL to execute the statement is provided at the end of this post):
    -- is this select distinct * and its associated where clause absolutely
    -- necessary to obtain the result ?
    select distinct *
      from (
            select s.sno,
                   s.sname,
                   s.age,
                   sum(case when t.cno in ('CS112', 'CS114')
                            then 1
                            else 0
                       end)
                     over (partition by s.sno) as takes_either_or_both
              from student s join take t
                               on (s.sno = t.sno)
      where takes_either_or_both = 1
    ;The following looked reasonable but, unfortunately unsuccessful:
      Window functions not allowed here (in Having Clause)
    select max(s.sno),
           max(s.sname),
           max(s.age),
           sum(case when t.cno in ('CS112', 'CS114')
                    then 1
                    else 0
               end)
             over (partition by s.sno) as takes_either_or_both
      from student s join take t
                       on (s.sno = t.sno)
    group by s.sno
    having sum(case when t.cno in ('CS112', 'CS114')
                    then 1
                    else 0
               end)
             over (partition by s.sno) = 1
    Invalid identifier in Having clause
    select s.sno,
           s.sname,
           s.age,
           sum(case when t.cno in ('CS112', 'CS114')
                    then 1
                    else 0
               end)
             over (partition by s.sno) as takes_either_or_both
      from student s join take t
                       on (s.sno = t.sno)
    group by s.sno, s.sname, s.age
    having takes_either_or_both = 1
    ;I have searched for a document that completely defines the sequence in which the clauses are executed. I have found tidbits here and there but not something complete. I realize that my running into problems like this one is due to my lack of understanding of the sequence and the scope of the clauses that make up a statement. Because of this, I cannot even tell if it is possible to write the above query using a single select statement. Pardon my bit of frustration...
    Thank you for your help,
    John.
    DDL follows.
            /* drop any preexisting tables */
            drop table student;
            drop table courses;
            drop table take;
            /* table of students */
            create table student
            ( sno integer,
              sname varchar(10),
              age integer
            /* table of courses */
            create table courses
            ( cno varchar(5),
              title varchar(10),
              credits integer
            /* table of students and the courses they take */
            create table take
            ( sno integer,
              cno varchar(5)
            insert into student values (1,'AARON',20);
            insert into student values (2,'CHUCK',21);
            insert into student values (3,'DOUG',20);
            insert into student values (4,'MAGGIE',19);
            insert into student values (5,'STEVE',22);
            insert into student values (6,'JING',18);
            insert into student values (7,'BRIAN',21);
            insert into student values (8,'KAY',20);
            insert into student values (9,'GILLIAN',20);
            insert into student values (10,'CHAD',21);
            insert into courses values ('CS112','PHYSICS',4);
            insert into courses values ('CS113','CALCULUS',4);
            insert into courses values ('CS114','HISTORY',4);
            insert into take values (1,'CS112');
            insert into take values (1,'CS113');
            insert into take values (1,'CS114');
            insert into take values (2,'CS112');
            insert into take values (3,'CS112');
            insert into take values (3,'CS114');
            insert into take values (4,'CS112');
            insert into take values (4,'CS113');
            insert into take values (5,'CS113');
            insert into take values (6,'CS113');
            insert into take values (6,'CS114');

    Hi, John,
    Just use the aggregate SUM function.
            select s.sno,
                   s.sname,
                   s.age,
                   sum(case when t.cno in ('CS112', 'CS114')
                            then 1
                            else 0
                       end) as takes_either_or_both
              from student s join take t
                               on (s.sno = t.sno)
           GROUP BY  s.sno,
                    s.sname,
                  s.age
           HAVING  sum(case when t.cno in ('CS112', 'CS114')
                            then 1
                            else 0
                       end)  = 1;Analytic functions are computed after the WHERE- and HAVING clause have been applied. To use the results of an analytic fucntion in a WHERE- or HAVING clause, you have to compute it in a sub-query, and then you can use it in a WHERE- or HAVING clause of a super-query.

  • Query to find duplicate records (Urgent!!!!)

    Hi,
    I have a to load data from a staging table to base table but I dont want to load data already present in the base table. Criteria to identify the duplicate data is thorugh a field say v_id and status_flag. If these two are the same in both staging and base table then that record must be rejected as a duplicate record.
    Kindly help me with the SQL which i need to use in a Procedure.
    Thanks

    Hello
    Another alternative would be to use MINUS if the table structures match:
    --Source rows the first 5 are in the destination table
    SQL> select * from dt_test_src;
    OBJECT_ID OBJECT_NAME
    101081 /1005bd30_LnkdConstant
    90723 /10076b23_OraCustomDatumClosur
    97393 /103a2e73_DefaultEditorKitEndP
    106075 /1048734f_DefaultFolder
    93337 /10501902_BasicFileChooserUINe
         93013 /106faabc_BasicTreeUIKeyHandle
         94929 /10744837_ObjectStreamClass2
        100681 /1079c94d_NumberConstantData
         90909 /10804ae7_Constants
        102543 /108343f6_MultiColorChooserUI
         92413 /10845320_TypeMapImpl
         89593 /10948dc3_PermissionImpl
        102545 /1095ce9b_MultiComboBoxUI
         98065 /109cbb8e_SpanShapeRendererSim
        103855 /10a45bfe_ProfilePrinterErrors
        102145 /10a793fd_LocaleElements_iw
         98955 /10b74838_SecurityManagerImpl
        103841 /10c906a0_ProfilePrinterErrors
         90259 /10dcd7b1_ProducerConsumerProd
        100671 /10e48aa3_StringExpressionCons
    20 rows selected.
    Elapsed: 00:00:00.00
    --Destination table contents
    SQL> select * from dt_test_dest
      2  /
    OBJECT_ID OBJECT_NAME
        101081 /1005bd30_LnkdConstant
         90723 /10076b23_OraCustomDatumClosur
         97393 /103a2e73_DefaultEditorKitEndP
        106075 /1048734f_DefaultFolder
         93337 /10501902_BasicFileChooserUINe
    Elapsed: 00:00:00.00
    --try inserting everything which will fail because of the duplicates
    SQL> insert into dt_test_dest select * from dt_test_src;
    insert into dt_test_dest select * from dt_test_src
    ERROR at line 1:
    ORA-00001: unique constraint (CHIPSDEVDL1.DT_TEST_PK) violated
    Elapsed: 00:00:00.00
    --now use the minus operator to "subtract" rows from the source set that are already in the destination set
    SQL> insert into dt_test_dest select * from dt_test_src MINUS select * from dt_test_dest;
    15 rows created.
    Elapsed: 00:00:00.00
    SQL> select * from dt_test_dest;
    OBJECT_ID OBJECT_NAME
        101081 /1005bd30_LnkdConstant
         90723 /10076b23_OraCustomDatumClosur
         97393 /103a2e73_DefaultEditorKitEndP
        106075 /1048734f_DefaultFolder
         93337 /10501902_BasicFileChooserUINe
         89593 /10948dc3_PermissionImpl
         90259 /10dcd7b1_ProducerConsumerProd
         90909 /10804ae7_Constants
         92413 /10845320_TypeMapImpl
         93013 /106faabc_BasicTreeUIKeyHandle
         94929 /10744837_ObjectStreamClass2
         98065 /109cbb8e_SpanShapeRendererSim
         98955 /10b74838_SecurityManagerImpl
        100671 /10e48aa3_StringExpressionCons
        100681 /1079c94d_NumberConstantData
        102145 /10a793fd_LocaleElements_iw
        102543 /108343f6_MultiColorChooserUI
        102545 /1095ce9b_MultiComboBoxUI
        103841 /10c906a0_ProfilePrinterErrors
        103855 /10a45bfe_ProfilePrinterErrors
    20 rows selected.You could use that in conjunction with the merge statement to exclude all trully duplicated rows and then update any rows that match on the id but have different statuses:
    MERGE INTO dest_table dst
    USING(     SELECT
              v_id,
              col1,
              col2 etc
         FROM
              staging_table
         MINUS
         SELECT
              v_id,
              col1,
              col2 etc
         FROM
              destination_table
         ) stg
    ON
         (dts.v_id = stg.v_id)
    WHEN MATCHED THEN....HTH

  • Reg: Find Duplicate Records and select max number of record in Table

    Hi Guys,
         This is Nagendra, India.
    my table structure is
    id  name  tempid  temptime
    1  xxx     123        date
    1 yyy       128       date
    1 sdd     173       date
    14 ree    184      date
    14 fded   189     date
    This is Table Structure, totally 15000+ records is there.
    My Requirement is showing id and max(tempId) value.
    id  name  tempid  temptime
    1   sdd    173      date
    14  fded   189     date
    Like that, I want to show all record(after hiding duplicate values ) like that Could you please solve this issue.
    With Regards,
    Nagendra

    ; WITH numbering AS (
        SELECT id, name, tempid, temptime,
               rowno = row_number() OVER(PARTITION BY id ORDER BY tempid DESC)
        FROM  tbl
    SELECT id, name, tempid, temptime
    FROM   numbering
    WHERE  rowno = 1
    The WITH thing defines a Common Table Expression which is a locally defined view which only exists for this query. The row_number function numbers the rows, re-starting on 1 for every id, and they are numbering in falling tempid order. Thus, by
    selecting all rows from the CTE with rono = 1, we get the row with the highest tempid for each id.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Difference in number of records in GROUP BY and PARTITION BY

    Hi Experts
    If I run the following query I got 997 records by using GROUP BY.
    SELECT c.ins_no, b.pd_date,a.project_id,
    a.tech_no
    FROM mis.tranche_balance a,
    FMSRPT.fund_reporting_period b,
    ods.proj_info_lookup c,
    ods.institution d
    WHERE a.su_date = b.pd_date
    AND a.project_id = c.project_id
    AND c.ins_no = d.ins_no
    AND d.sif_code LIKE 'P%'
    AND d.sif_code <> 'P-DA'
    AND a.date_stamp >='01-JAN-2011'
    AND pd_date='31-MAR-2011'
    GROUP BY c.ins_no,
    b.pd_date,
    a.project_id,
    a.tech_no;
    I want to show the extra columns a.date_stamp and a.su_date
    in the out put so that I have used PARTITION BY in the second query but I got 1079 records.
    SELECT c.ins_no, b.pd_date,a.date_stamp,a.su_date, a.project_id,
    a.tech_no,
    COUNT(*) OVER(PARTITION BY c.ins_no,
    b.pd_date,
    a.project_id,
    a.tech_no)c
    FROM mis.tranche_balance a,
    FMSRPT.fund_reporting_period b,
    ods.proj_info_lookup c,
    ods.institution d
    WHERE a.su_date = b.pd_date
    AND a.project_id = c.project_id
    AND c.ins_no = d.ins_no
    AND d.sif_code LIKE 'P%'
    AND d.sif_code <> 'P-DA'
    AND a.date_stamp >='01-JAN-2011'
    AND pd_date='31-MAR-2011'
    Please help me why I got 1079 records.
    And also please help me how to show the two extra columns in the out put whcich are not used in
    GROUP BY clause.
    Thanks in advance.

    Hi,
    user9077483 wrote:
    Hi Experts
    If I run the following query I got 997 records by using GROUP BY. ...Let''s call this "Query 1", and the number of rows it returns "N1".
    The results tell you that there are 997 distinct combinations of the GROUP BY columns (c.ins_no, b.pd_date, a.project_id, a.tech_no).
    I want to show the extra columns a.date_stamp and a.su_date
    in the out put so that I have used PARTITION BY in the second query but I got 1079 records. ...Let's call the query without the GROUP BY "Query 2", and the number of rows it returns "N2".
    Please help me why I got 1079 records.Because there are 1079 rows that meet all the GROUP BY conditions. Query 2 has nothing to with distinct values in any columns. You would expect that N2 to be at least as high as N1, but it's not surprising that the N2 is higher than N1.
    And also please help me how to show the two extra columns in the out put whcich are not used in
    GROUP BY clause.Doesn't Query 2 show those two columns already? If the Query 2 is not producing the results you want, then what results do you want?
    Post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data. Point out a couple of places where Query 2 is not doing what you want.
    Always say which version of Oracle you're using.

  • Debit memo will be finded two record after be modified and reconfirmed.

    We have set two types of debit memo in system, itu2019s LV and DR, it have a process of confirm before invoicing, when a new LV debit memo has been confirmed first then revoked, it has been modified and reconfirmed second, we found the LV debit memo built two terms in billing due list and the first record was remained even the memo was deleted, so I think it may be a bug of system

    voiceoverworkshop wrote:
    The gist of it is, run the phone line (with caller) through the telephone interface and into a channel on the mixer, where you can control the callers volume, and tweak the eq (if the mixer supports that). Run your voice through the microphone, into another channel on the mixer, where you can control your volume and tweak your eq if the mixer supports it. Run the output of the mixer to Audition. 
    Nothing wrong with this at all, but I think that one particular point isn't perhaps quite as clear as it could be - and that is that ideally, you should pan the channels (assuming it's a stereo output) so that for the initial recording, the caller is on one channel, and that you are on the other. That way, you don't have to worry so much during the interview that you're keeping all the levels exactly as they should be, and can concentrate on the interview itself. Then, after the event you can optimise just the caller channel so that it sounds best, without worrying about having to select bits of caller from two channels mixed.
    The other thing I should mention is that the best results I've had from doing something similar involve a small mixer, with outputs panned pretty much as described, and using Skype. With a little care, you can almost get it sounding like the caller is in the studio with you.

  • SQL group by and having

    I have a table having columns business_name ,sales,state,zip.
    I would like to know count of businesses having sales 0-50 and
    count of businesses having sales50-100, and 100-150 and so on.
    can i write single query to gent count of business for all these ranges,instead of
    writing seperate query for each range. If possible please tell me how?

    SELECT sum(case
                  when sales between 0 and 50 then 1
                  else 0
               end
              ) sales_0_50
          ,sum(case
                  when sales between 51 and 100 then 1
                  else 0
               end
              ) sales_51_100
          ,sum(case
                  when sales between 101 and 150 then 1
                  else 0
               end
              ) sales_101_150
          ,sum(case
                  when sales > 150 then 1
                  else 0
               end
              ) sales_over_150
    FROM   biz_table;

  • Find duplicate records

    Hi,
    I have a 800,000-row table with unique ID. Recently we're given criteria for record duplication based on 7 out of 20 table's columns. We would like know which record ID has duplication value based on the exact match of those 7 columns.
    Example
    ID PRODUCT DEPT LEVEL
    ============================
    1 PRINTER ABC 1
    2 PRINTER ABC 2
    3 PRINTER DEF 2
    4 TOMER ABC 3
    If new criteria of duplication is based on the exact data match of column PRODUCT and DEPT, record ID 1 and 2 are considered duplicated.
    Is there any easy way to it on 800,000 row table?
    Thanks in advance
    -i

    here is some examples that might be of help.
    SQL> select * from employees;
    YEAR EM NAME       PO
    2001 02 Scott      91
    2001 02 Scott      01
    2001 02 Scott      07
    2001 03 Tom        81
    2001 03 Tom        84
    2001 03 Tom        87
    6 rows selected.
    SQL> select year, empcode, name, position,
      2         row_number() over (partition by year, empcode, name
      3                            order by year, empcode, name, position) as rn
      4    from employees;
    YEAR EM NAME       PO         RN
    2001 02 Scott      01          1
    2001 02 Scott      07          2
    2001 02 Scott      91          3
    2001 03 Tom        81          1
    2001 03 Tom        84          2
    2001 03 Tom        87          3
    6 rows selected.
    SQL> Select year, empcode, name, position
      2    From (Select year, empcode, name, position,
      3                 row_number() over (partition by year, empcode, name
      4                                    order by year, empcode, name, position) as rn
      5            From employees) emp
      6   Where rn = 1;
    YEAR EM NAME       PO
    2001 02 Scott      01
    2001 03 Tom        81
    SQL>

  • Find a record that doesnt exist and display a message

    When I run the following query why wont it display the word 'FAIL'.
    SELECT
      CASE
        WHEN table_name IN('DBA_OBJECTS') THEN 'PASS'
        ELSE 'FAIL'
      END TABLE_EXISTS
    FROM dictionary
    WHERE table_name = 'DBA_OBJECT'
    ;Ben

    Hi Benton,
    The query filter (WHERE table_name = 'DBA_OBJECT') cause zero record to be returned.
    To trick you can use aggregate function which always return single record even if record is found or not. If no record is found then NULL is returned.
    SQL> SELECT CASE WHEN MAX(table_name) IN('DBA_OBJECTS') THEN 'PASS' ELSE 'FAIL' END TABLE_EXISTS -- OR NVL2(MAX(table_name),'PASS','FAIL') TABLE_EXISTS
      2  FROM dictionary
      3  WHERE table_name = 'DBA_OBJECT'
      4  AND ROWNUM = 1
      5  /
    TABLE_EXISTS
    FAIL
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Group by clause and having clause in select

    hi frnds
    plz give me some information of group by and having clause used in select statement with example
    thanks

    The Open SQL statement for reading data from database tables is:
    SELECT      <result>
      INTO      <target>
      FROM      <source>
      [WHERE    <condition>]
      [GROUP BY <fields>]
      [HAVING   <cond>]
      [ORDER BY <fields>].
    The SELECT statement is divided into a series of simple clauses, each of which has a different part to play in selecting, placing, and arranging the data from the database.
    You can only use the HAVING clause in conjunction with the GROUP BY clause.
    To select line groups, use:
    SELECT <lines> <s1> [AS <a1>] <s2> [AS <a2>] ...
                   <agg> <sm> [AS <am>] <agg> <sn> [AS <an>] ...
           GROUP BY <s1> <s2> ....
           HAVING <cond>.
    The conditions <cond> that you can use in the HAVING clause are the same as those in the SELECT clause, with the restrictions that you can only use columns from the SELECT clause, and not all of the columns from the database tables in the FROM clause. If you use an invalid column, a runtime error results.
    On the other hand, you can enter aggregate expressions for all columns read from the database table that do not appear in the GROUP BY clause. This means that you can use aggregate expressions, even if they do not appear in the SELECT clause. You cannot use aggregate expressions in the conditions in the WHERE clause.
    As in the WHERE clause, you can specify the conditions in the HAVING clause as the contents of an internal table with line type C and length 72.
    Example
    DATA WA TYPE SFLIGHT.
    SELECT   CONNID
    INTO     WA-CONNID
    FROM     SFLIGHT
    WHERE    CARRID = 'LH'
    GROUP BY CONNID
    HAVING   SUM( SEATSOCC ) > 300.
      WRITE: / WA-CARRID, WA-CONNID.
    ENDSELECT.
    This example selects groups of lines from database table SFLIGHT with the value ‘LH’ for CARRID and identical values of CONNID. The groups are then restricted further by the condition that the sum of the contents of the column SEATSOCC for a group must be greater than 300.
    The <b>GROUP BY</b> clause summarizes several lines from the database table into a single line of the selection.
    The GROUP BY clause allows you to summarize lines that have the same content in particular columns. Aggregate functions are applied to the other columns. You can specify the columns in the GROUP BY clause either statically or dynamically.
    Specifying Columns Statically
    To specify the columns in the GROUP BY clause statically, use:
    SELECT <lines> <s1> [AS <a 1>] <s 2> [AS <a 2>] ...
                   <agg> <sm> [AS <a m>] <agg> <s n> [AS <a n>] ...
           GROUP BY <s1> <s 2> ....
    To use the GROUP BY clause, you must specify all of the relevant columns in the SELECT clause. In the GROUP BY clause, you list the field names of the columns whose contents must be the same. You can only use the field names as they appear in the database table. Alias names from the SELECT clause are not allowed.
    All columns of the SELECT clause that are not listed in the GROUP BY clause must be included in aggregate functions. This defines how the contents of these columns is calculated when the lines are summarized.
    Specifying Columns Dynamically
    To specify the columns in the GROUP BY clause dynamically, use:
    ... GROUP BY (<itab>) ...
    where <itab> is an internal table with line type C and maximum length 72 characters containing the column names <s 1 > <s 2 > .....
    Example
    DATA: CARRID TYPE SFLIGHT-CARRID,
          MINIMUM TYPE P DECIMALS 2,
          MAXIMUM TYPE P DECIMALS 2.
    SELECT   CARRID MIN( PRICE ) MAX( PRICE )
    INTO     (CARRID, MINIMUM, MAXIMUM)
    FROM     SFLIGHT
    GROUP BY CARRID.
      WRITE: / CARRID, MINIMUM, MAXIMUM.
    ENDSELECT.
    regards
    vinod

Maybe you are looking for