Way To Eliminate Duplicates

Jun 11, 2013

I have a table like below:

tableA
aid des
1 concrete
2 wood
3 straw
4 plastic
5 fiber glass
6 other

tableB
bid material
01 1
02 2
03 3
01 2
01 2
02 3
01 5

The result I need when updating another table with this info is:TableC
edw_id bid Requirement
021 1 concrete, wood, fiber glass
032
025
123
521

I do not want :
concrete, concrete, concrete, wood, wood, fiber glass

SO far I am using the following but since I am dealing with hundreds of column that has the same material, when using listagg() from oracle 11.2g, they column width is too wide to fit into the required column.

update eris_data_work e set E.flex37 =
(select
LISTAGG(CM.des, ',') WITHIN GROUP (ORDER BY CM.des) AS casing_material
from CODE_CASING_MATERIAL CM, TBLCASING CA
where CM.code=CA.MATERIAL and CA.well_id=E.owner_oid AND CM.DES IS NOT NULL
GROUP BY CA.well_id)
where E.source='WWIS_ON'

I have even used the regexp_count() to try to eliminate duplicates however I have had no success so far

View 4 Replies


ADVERTISEMENT

PL/SQL :: How To Eliminate Duplicates From Record Types

Aug 21, 2013

How to eliminate duplicates from record types?Below code errors out with "Wrong number of arguments in call to MULTISET...."

error. DeclareTYPE ln_x_tab IS RECORD(x1 number ,x2 VARCHAR2(4000) ,x3 VARCHAR2(4000) ,x4 VARCHAR2(4000) ,x5 VARCHAR2(4000));  TYPE  ln_x_type IS TABLE OF ln_x_tab INDEX BY BINARY_INTEGER; ln_x1 ln_x_type; ln_dist_x1  ln_x_type; gc_stmt     varchar2(4000); Begin   gc_stmt := ' SELECT x1, x2, x3, x4, x5 FROM table WHERE dynamic_conditions;    EXECUTE IMMEDIATE gc_stmt BULK COLLECT INTO ln_x1;  ln_dist_x1:=      ln_x1 MULTISET UNION DISTINCT ln_x1; End; 

I need ln_dist_x1 to have distinct records from table.

View 12 Replies View Related

Using <> To Eliminate Two Codes?

Mar 17, 2009

I am writing my first procedure and need to exclude two codes from a list of receipts. I can probaby use the following

and rc_receipt_code in (1, 2, 3, 4, 7, 8)

however can I use <> to eliminate 2 codes for instance can I say

select NVL(sum(rc_amt), 0)
into tot_cont
from trefrc
where rc_filer_seq = filer
and rc_receipt_code <> (5, 6);

View 1 Replies View Related

Eliminate Duplicate Rows

Jan 27, 2009

I have to eliminate duplicate pairs from the following data set.

for ex. Adney Vaughan and Berkly Wassen appears in both AG1 and AG2. how can i get rid of these repititive rows?

AG1 ----------- AG2
Acton Wibert ---- Currier Barhydt
Adney Vaughan --- Luella Edmund
Adney Vaughan --- Berkly Wassen
Alden Anstruther --- Courtney Gavet
Ashley Alvord --- Saunders Buel
Aswin Wilbraham --- Dale Cooper
Barnum Sears --- Grayson Lightfoot
Berkly Wassen --- Luella Edmund
Berkly Wassen --- Adney Vaughan
Bersh Musgrave --- Derward Knight
Berthilda Darrell --- Broderick Reynold
Broderick Reynold --- Berthilda Darrell

View 1 Replies View Related

SQL & PL/SQL :: Eliminate Spaces Between Values

Nov 2, 2011

i can't eliminate the spaces between values, i tried to use rtrim but still failed.

Set pagesize 0
set linesize 1000
set heading off
set feedback off
set colsep '|'
SELECT '200', '20002977', T0.TP, T0.Description, T2.FirstName, T2.LastName, 'Geography Code', SUBSTR(T3.aoManager, -6,5)
[code]....

View 6 Replies View Related

SQL & PL/SQL :: How To Eliminate And Separate String

Apr 29, 2011

In my table i have a field called swistmsg, which contains value as

:201:0001OTT11000004|:23b1:CRED|:32a1:01-01-2011|:32a2:USD|:
32a3:1000.|:33b1:USD(similarly around 100 rows)

and my requirement is

201 0001OTT11000004 23b1 CRED 32a1 01-01-2011 32a2 USD 32a3 1000 33b1 USD

and i have eliminate '.',':'&'|' (only quoted chars)from the string separate string

View 17 Replies View Related

SQL & PL/SQL :: Eliminate Default Time 12:00 Am

May 10, 2012

I have a table with Date Field . While selecting the records its display like below format.

TO_CHAR(CHAR_DATE,'DD-MM-RRRRHH:MI:SSAM')

10-05-2012 12:00:00 AM
10-05-2012 03:26:16 PM

1 row doesnt have time, but in default it shows 12:00:00 AM, how to eliminate it. Display should be

10-05-2012
10-05-2012 03:26:16 PM

create table time_test (char_date date);

INSERT INTO TIME_TEST ( CHAR_DATE ) VALUES (
TO_Date( '05/10/2012', 'MM/DD/YYYY HH:MI:SS AM'));
INSERT INTO TIME_TEST ( CHAR_DATE ) VALUES (
TO_Date( '05/10/2012 03:26:16 PM', 'MM/DD/YYYY HH:MI:SS AM'));
COMMIT;

select TO_char(CHAR_DATE,'dd-mm-rrrr HH:MI:SS AM') from time_test;

i need in to_char only, im using it in reports

View 4 Replies View Related

SQL & PL/SQL :: How To Eliminate Duplicate Values From Table

Nov 24, 2011

I need to delete the duplicate values from plsql table OR move the distinct values in plsql table to other plsql table.

how can i do this ?

DECLARE
TYPE alist IS TABLE OF VARCHAR2(10) INDEX BY BINARY_INTEGER;
p_tbl alist;
BEGIN
p_tbl(1) := 'A1';
p_tbl(2) := 'B2J';
p_tbl(3) := 'A1';
[code]......

The p_tb1 table contains all the above values including duplicates. Now I need only distinct values to be copied in another plsql table of same type.

View 14 Replies View Related

SQL & PL/SQL :: Query To Eliminate Multiple Spaces?

Mar 5, 2010

I need to eliminate the blank spaces based on below conditions Consider name column with a value as

Input : "sa c h in Te nd ulka r" where "Sachin" is first name and "Tendulkar" is last name. there is more than 1 space between sachin and tendulkar (here its not displaying properly)

Condition :Second name is seperated from first name with more than 1 spaces and others are with 1 black space. I need to get result as Output:"sachin Tendulkar" ( there should be 1 blank space between first and last name in result.)

View 3 Replies View Related

PL/SQL :: How To Eliminate Null Rows From The Result Set

Jul 10, 2012

My requirement is as follows .

Oracle version details
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
PL/SQL Release 11.1.0.7.0 - Production
CORE     11.1.0.7.0     Production
TNS for 32-bit Windows: Version 11.1.0.7.0 - Production

[code]....

View 6 Replies View Related

How To Eliminate Windows NT Authentication In Oracle DB Server

Feb 18, 2013

I have oracle database server set with Windows NT authentication. How can I get rid of this kind of authentication as this is holding up additional Windows Domain with its own PDS and so on. Or is it possible to move Oracle Database server to a different Domain and authentication to be coming from new domain?

View 4 Replies View Related

SQL & PL/SQL :: Using Regexp_replace To Eliminate Duplicate String With Delimiter

Sep 11, 2013

I'm trying to eliminate duplicate string for more than 1 occurrences along with its delimiters, but couldn't get it working. Here is what I tried.

SQL> column str format a30
SQL> column replaced format a30
SQL> with x as
2 (select 'a#~#b#~#a#~#d' as str from dual union all
3 select 'a#~#b#~#c#~#a' as str from dual union all
4 select 'b#~#a#~#c#~#a' as str from dual)
select str,
regexp_replace(str, '[^a|#~#a]{2,}','',1,2) replaced
from x; 5 6 7

STR REPLACED
------------------------------ ------------------------------
a#~#b#~#a#~#d a#~#b#~#a#~#d
a#~#b#~#c#~#a a#~#b#~#c#~#a
b#~#a#~#c#~#a b#~#a#~#c#~#a

The output I need is
a#~#b#~#d
a#~#b#~#c
b#~#a#~#c

View 12 Replies View Related

SQL & PL/SQL :: Write A Function To Eliminate SUNDAY AND SATURDAY?

May 9, 2012

i need to write a function to eliminate SUNDAY AND SATURDAY;

My criteria is

if My date as (5/19/2012 ) and i want to add 10 days to it themn my function should return 06/01/2012
if My date as (5/13/2012 ) and i want to add 12 days to it themn my function should return 05/29/2012

View 11 Replies View Related

SQL & PL/SQL :: Eliminate Donor With Multi Topic Code

Apr 27, 2012

Below is an overs implication of what I need to extract from a donor list and am having some difficulty pulling the correct targets. I need to pull a donor who has had only one topic in the past year.

I only want id number 100 and not 120 since 120 has three topics in the past year, I tried using not exists...etc and can't seem to get the donors with the one topic 'HC' that is being requested.

example:

create table Topic(Idnumber number(8),topic varchar2(4));
INSERT INTO Topic(idnumber,topic)
VALUES (100, 'HC')
/
INSERT INTO Topic(idnumber,topic)
VALUES (120, 'HC')
/
[code].......

IDNUMBER TOPI
---------- ----
100 HC
120 IRS
120 PRS
120 HC

SQL> select idnumber from topic where topic in('HC');

IDNUMBER
----------
100
120

SQL> select idnumber from topic where topic in ('HC') and topic not in('IRS','PRS');

IDNUMBER
----------
100
120

View 12 Replies View Related

Client Tools :: How To Eliminate Blank Lines In Between Queries In Output

Apr 28, 2010

I am spooling to a text file some output for a client. The file has 4 queries in it, one creates a header row, another a comment row, another the data rows and finally a trailer.

Code looks something like this:

/*
Custom Extract
Project: Plan Data Extract
Product: EOWin 4.02 - Oracle db
Use: Script to create above extract and spool results to text file
Input Parameters: &1 Path and name of output file
*/

[code]....

and the output looks like this:

HDR,04272010,Plan Data

CMT,Plan Num,Plan ID,Plan Name,Shares Allocated

DAT,1,01,Plan 01,99999999
DAT,2,02,Plan 02,99999999
DAT,3,03,Plan 03,99999999
DAT,4,04,Plan 04,99999999
FTR,4

but the client and I want the output to look like this with no blank lines in between the queries:

HDR,04272010,Plan Data
CMT,Plan Num,Plan ID,Plan Name,Shares Allocated
DAT,1,01,Plan 01,99999999
DAT,2,02,Plan 02,99999999
DAT,3,03,Plan 03,99999999
DAT,4,04,Plan 04,99999999
FTR,4

View 3 Replies View Related

Self Joins Getting Rid Of Duplicates?

Jun 17, 2008

I have a table1:
userid, name, town.

Now i want to do a self join like:

select a.name, b.name, a.town
from table1 a
inner join table1 b
on a.town = b.town
where a.first_name <> b.first_name AND
a.last_name <> b.last_name

i added the where clause to limit duplicates i would get but i still get duplicates eg. A B london, B A london etc.

View 9 Replies View Related

SQL & PL/SQL :: Best Way To Find Duplicates?

Feb 14, 2012

I have to load 50 Million records in a table. I also need to ensure that no duplicate records enter. Business demand is that It may send 2 Million records today, 1 Million records tomorrow, 3 million records on the next day and so on...

I have loaded 6 Million records into the table, but onwards speed of loading records (with duplicate check) is decreasing.

View 16 Replies View Related

SQL & PL/SQL :: Pick One Out Of Duplicates?

Jul 19, 2010

I have need, where I need to pick-up the one of the records out of 2, which have all the fields same but one key column? how should I do it?

sample data:

IDnamecreation dateupdate date
121233ATR7/19/2010 15:307/19/2010 15:30
1213344MTR7/19/2010 15:307/19/2010 15:30

For most of the cases, i am picking latest data using update date, but here where dates are same, I am stuck.

View 2 Replies View Related

PL/SQL :: Removing Duplicates Except One

Sep 19, 2013

db and dev 10g rel2 ,suppose that i have a table with a lot of duplicate rows ,what i need is to delete the duplicates and retain one row of these duplicates . likecolumn -- with those values...how to delete two (hi's) and retain the third , ?it is all applied to all the duplicate values in the column.

View 5 Replies View Related

SQL & PL/SQL :: How To Remove Duplicates From Collection

Mar 24, 2011

remove duplicates from my collection(table type).Or an alternate solution for my issue is get clean data into my collection which i am not able to get to either.

Object creation

create table testingtype_table(ordernumber number,org_id number , company_name varchar2(10))
insert into testingtype_table values (1124,2424,'cbaaa');
insert into testingtype_table values (1124,2424,'cbaaa');

create or replace type testingtype_obj as object (ordernumber number,org_id number , company_name varchar2(10));
create or replace type testingtype_tab as table of testingtype_obj;

Code Block
declare
l_testingtype_tab testingtype_tab := testingtype_tab();
begin
select distinct testingtype_obj(ordernumber
,org_id
,company_name)
bulk collect into l_testingtype_tab
from testingtype_table;
end;

If only i can get a way to bulk collect only distinct values into the table type that will just do great but when i try the above (with distinct highlighted in red) it throws an error

ORA-22950: cannot ORDER objects without MAP or ORDER method

View 4 Replies View Related

SQL & PL/SQL :: Remove String Duplicates

Oct 11, 2013

Removing duplicates from a string that contains years and "-".

Example: 1988-1997-2000-2013-1998-1965-1997-1899

I know this can be done in regular expressions but have no experience in this subject.

select REGEXP_REPLACE(.....) from dual;

View 16 Replies View Related

SQL & PL/SQL :: Remove Repeating Duplicates

Aug 3, 2011

i have two tables

Quote:
Table has following data.

id indicator
---------------
1 A
2 A
3 A

Quote:
Table2 has

id indicator
---------------
1 X
1 X
2 X
3 X

I would like to have following output ( Am running query on Toad)

t1_id t1_indicator t2_id t2_indicator
---------------------------------------------
1 A 1 X
1 X
2 A 2 X
3 A 3 X

View 4 Replies View Related

SQL & PL/SQL :: Get A Specific Record In Duplicates

Aug 17, 2012

I have a requirement with source table has duplicates so i need to select a row based upon the below condition.

Source table

EMP_NO ENAME SALARY CODE EMP_ID
1 TOM 1000 1 10
1 JOHN 2000 A 20
1 SAM 3000 A 30

2 TOM 500 1 40
2 SUNG 1500 1 50

Desired Output

EMP_NO ENAME SALARY CODE EMP_ID
1 TOM 1000 1 10
2 SUNG 1500 1 50

I tried with MAX and DENSE_RANK but its not getting me the first row.

View 8 Replies View Related

PL/SQL :: Inner Join Resulting In Many To Many Duplicates

Oct 9, 2013

I ran an Inner Join but it returned many, many duplicates. One Answer from a different thread:Because you may be having improper Join condition what has a One to many or a Many to many relationship between the tables. We do not have the data, and hence cannot comment over it. What do I look for to identify an improper join?

View 2 Replies View Related

PL/SQL :: Get A Specific Record In Duplicates?

Aug 17, 2012

I have a requirement with source table has duplicates so i need to select a row based upon the a condition.

Source table

EMP_NO ENAME SALARY CODE EMP_ID

1 TOM 1000 1 10
1 JOHN 2000 A 20
1 SAM 3000 A 30
2 TOM 500 1 40
2 SUNG 1500 1 50

Desired Output

EMP_NO ENAME SALARY CODE EMP_ID
1 TOM 1000 1 10
2 SUNG 1500 1 50

I tried with MAX and DENSE_RANK but its not getting me the first row.

View 6 Replies View Related

PL/SQL :: Remove Duplicates From A Column

Nov 8, 2012

I want to remove duplicates from a column MAIN_TABLE based on TLEVEL Column:

create table UNIQ_TEMP
( TLEVEL NUMBER(10,0),
TABLE_NAME VARCHAR2(30),
MAIN_TABLE VARCHAR2(30)
);
[code]....

My Requirement is:

MAIN_TABLE= MARKETING_OPTIN
EXISTS IN MAX(TLEVEL)
REMOVE DUPLICATE MARKETING_OPTIN FROM OTHER LEVELS

This should apply to all the values in column MAIN_TABLE

View 12 Replies View Related

Flexible Handling Of Duplicates Using A Trigger

Feb 12, 2007

I'd like to achieve the following (and YES, I do know that this is not multi-user safe, but that's not the point here):

Before inserting a record, the trigger shall check if there's already a duplicate one. Duplicate means in this case when there is an intersection of the time frame, defined by two numeric timestamps. That's also the cause why I cannot use a simple UNIQUE constraint here (in my opinion).

Okay, that already works (see code below). But now I need colliding records to be written to a temporary table so that those records can be returned and presented to the user for selection.

create or replace
TRIGGER TRIGGER1
BEFORE INSERT ON FLIGHT_TABLE
FOR EACH ROW
BEGIN
FOR fs_entry IN (SELECT * FROM FLIGHT_TABLE)
LOOP

[Code] .........

View 1 Replies View Related

SQL & PL/SQL :: How To Make Return All Records Except Duplicates

Mar 29, 2010

I have a table like this basic example:

ID Product Color Time-In
1 Apple Green May
2 Apple Red April
3 Pear Green May
4 Pear Green April
5 Plum Blue June

In SQL I want to return all 4 fields of the records except those records where Product and Color are identical - in that case it should return the latest (by name of month - preferred) or just the first it finds

So I should get these

1 Apple Green May
2 Apple Red April
3 Pear Green May
5 Plum Blue June

If I do a select distinct then I will only get those fields I test on (product and color), not the rest.

View 1 Replies View Related

SQL & PL/SQL :: Delete Duplicates From Table Without Using Rowid?

Mar 30, 2010

I am trying to delete duplicates from table without using rowid.

here is data:-

create table test(col1 number(3),col2 varchar2(20));
insert into test values(100,'rocky');
insert into test values(100,'rocky');

[Code]....

I know i am perfoming dml on view. IT wont allow me to perform DML on view which contain columns with expression. IS there any way to delete duplicates without using rowid?

View 36 Replies View Related

SQL & PL/SQL :: Get Distinct / First Record From Jungle Of Duplicates?

Aug 30, 2010

I am trying to work with query to get distinct unique records, following is my scenerio:

DocNo |Title| Revs|UpdateTime|OBID
DOC-101|DESCRIPTION1|1|2/28/2004 11:37|6108-9
DOC-101|DESCRIPTION1|1|2/28/2004 11:36|6106-13
DOC-201|DESCRIPTION2|0|4/24/2005 16:44|7899-1

[code]...

From the above duplicates I would like to get only 1 distinct record based on latest update time (when using distinct on a sub-query since OBID is unique again returning all recds)

I am expecting results like:
DocNo|Title| Revs|UpdateTime|OBID
DOC-101|DESCRIPTION1|1|2/28/2004 11:37|6108-9
DOC-201|DESCRIPTION2|0|4/24/2005 16:47|7900-1
DOC-301|DESCRIPTION3|3|2/21/2007 7:26|6869-4
DOC-304|DESCRIPTION4|3|8/22/2007 9:31| 39208-1

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved