omit the duplicate lines
Hi gurus,I have a table with the following structure
Col col2
------------------
1 2
1 3
4 w
2 3
4 1
4 2
logically the 1.2 line is equivalent to 2, 1.so query should retrieve only the records with values col 1, 2-1, 3-2, 3-4, 1-4, 2.
Could it please let you me know the query for this... am breaking my head for this solution.
Best regards
Sridhar
OLAP is very useful :-)
Samples of my home page B - OLAP)
http://www.geocities.jp/oraclesqlpuzzle/Oracle-SQL1-OLAP.html
with t(col1,col2) as(
select 1,2 from dual union all
select 1,3 from dual union all
select 2,1 from dual union all
select 2,3 from dual union all
select 4,1 from dual union all
select 4,2 from dual)
select col1,col2
from (select col1,col2,
min(col1)
over(partition by least(col1,col2),
greatest(col1,col2)) as minCol1
from t)
where col1 = minCol1
order by col1,col2;
COL1 COL2
---- ----
1 2
1 3
2 3
4 1
4 2
Tags: Database
Similar Questions
-
change the size of the table and remove the duplicate line
Hello
I run a program that does a for loop 3 times. In each loop, the data are collected for x and y points (10 in this example). How can I output the table with 30 points in a simple 2D array (size 2 x 30)?
Moreover, from the table, how to delete duplicate rows that contain the same value of x?
Thank you
hiNi.
He probaibly which would have allowed to attach a file that has a consecutive duplicate lines.
Here is a simple solution.
-
Help! Trying to amount of money with the duplicate lines
I have a database that have the code bars the columns following, quantity, etc.. The barcode colum has duplicates of bar code and the corresponding quantity is different. I worked hours trying to solve how to summarize each different bar codes and replace the table with 1 bar code each corresponding total quantity. For example, instead of:
97138644756 3 97138644756 2 97138644756 1 97138660565 5 97138660565 4 97138661777 1 97138662224 1 97138670403 1 97138679239 1 97138714978 1 97138716262 1 97138739667 6 97138739667 7 97138739667 8 I would like that it follows:
97138644756 6 97138660565 9 97138661777 1 97138662224 1 97138670403 1 97138679239 1 97138714978 1 97138716262 1 97138739667 21 I used the following code, which selects only duplicates.
< cfquery name = "CountBarcodesCart1" datasource = "inventory" >
SELECT *.
OF cart1
WHERE barcode (IN)
SELECT bar code
OF cart1
GROUP BY barcode
SEEN (COUNTING (barcode) > 1))
< / cfquery >
Thanks for anyone who can help with my business.
I know there are much better to do this, but I'll share the following code and hope it helps someone else. What I did change table CART1 to a TEMP table, get the added dupliates and then copy the corrected (with no duplicates) to a new data table. Then I delete the TEMP table.
SELECT the barcode, Sum (Quantity) as the quantitysum
TEMP
GROUP BY barcode
INSERT INTO Cart1 (bar code, quantity)
VALUES (#CountBarcodesTemp.barcode #, #CountBarcodesTemp.quantitysum #)
#barcode #-#QuantitySum #.
DELETE *.
TEMP
-
Need to return the duplicate lines
Hello
I have two data different sets as below:
SERIES 1:
col1 col2 col3
2 cust1 NULL
3 cust2 NULL
1 cust NULL
1 cust NULL
SERIES 2:
col1 col2 col3
1 prod NULL
1 prod NULL
2 NULL prod1
3 NULL prod2
The join column is 'col1' (for both sets). Now where there is duplicated in col1; lines Col2 is also double for VALUE 1 and col3 is duplicated for SET 2 and I want the lines in the output as:
col1 col2 col3
1 cust prod
1 cust prod
2 cust1 prod1
3 cust2 prod2
Can you please let me know the best way to achieve this.
Kind regards
MiloudThis operation generates your output given your input samples example, but I don't know why you want four lines instead of the six that would come because of the duplication of the set1.
SQL> WITH set1 AS ( 2 SELECT 2 col1, 'cust1' col2, NULL col3 FROM dual UNION ALL 3 SELECT 3, 'cust2', NULL FROM dual UNION ALL 4 SELECT 1, 'cust', NULL FROM dual UNION ALL 5 SELECT 1, 'cust', NULL FROM dual), 6 set2 AS ( 7 SELECT 1 col1, NULL col2, 'prod' col3 FROM dual UNION ALL 8 SELECT 1, NULL, 'prod' FROM dual UNION ALL 9 SELECT 2, NULL, 'prod1' FROM dual UNION ALL 10 SELECT 3, NULL, 'prod2' FROM dual) 11 SELECT s1.col1 s1c1, s1.col2 s1c2, s2.col3 s2c3 12 FROM (SELECT distinct col1, col2, col3 FROM set1) s1 13 JOIN set2 s2 14 ON s1.col1 = s2.col1; S1C1 S1C2 S2C3 ---------- ----- ----- 1 cust prod 1 cust prod 2 cust1 prod1 3 cust2 prod2
John
-
the selection of column in the row for the duplicate line
Dear Sir.
Please help me with a query
Select the value of the column in the value of line when the line is repeated by the value of Column2 order.
col1 col2
Row1 1 d
row2 1 b
row3 1 c
row3 2 c
row4 2 d
row5 2A
my application should choose as below
col1 col2 col3 col4
Row1 1 c b d
row2 2A c and d
Please help I really need
Thanks and greetings
SanatFrank gave you the answer...
Here's anotherSQL> create table test 2 as 3 select 1 col1, 'a' col2 from dual union all 4 select 1 col1, 'd' col2 from dual union all 5 select 1 col1, 'e' col2 from dual union all 6 select 2 col1, 'b' col2 from dual union all 7 select 2 col1, 'd' col2 from dual union all 8 select 2 col1, 'e' col2 from dual union all 9 select 3 col1, 'c' col2 from dual union all 10 select 3 col1, 'a' col2 from dual union all 11 select 3 col1, 'd' col2 from dual 12 ; Table created. SQL> SQL> select col1 2 , max (decode (rn, 1, col2)) col2 3 , max (decode (rn, 2, col2)) col3 4 , max (decode (rn, 3, col2)) col4 5 from ( 6 select col1 7 , col2 8 , row_number () over (partition by col1 9 order by col2 10 ) rn 11 from test 12 ) 13 group by col1 14 / COL1 C C C ---------- - - - 1 a d e 2 b d e 3 a c d
-
Remove the duplicate line based on master e-mail
Hello
I have a request below that displays the records in doubles because of the tips white space I like how ignore and get a single record.
Select
SEPARATE
MASTER_EMAIL "E-mail account"
"Name",
Last_name "Last Name."
Decode (company_name, NULL, Domain, company_name) "society."
JOB_FUNCTION "Title."
Ligne_adresse_1 "address."
"CITY."
"STATE."
'COUNTRY ', HE SAID.
"Zip, ZIP
PHONE_NUMBER "phone."
FAX_NUMBER "Fax."
CREATED_DATE "created Date."
FIELD,
MASTER_FLAG,
location_company_name
of master_email_users
where
MASTER_EMAIL AS ' [email protected] % %'
Thank you
Sudhir
What I feel is best to remove the white space in the data itself by refreshing the records where we have and making sure that no future records cannot have white space while getting inserted.
This helps us to avoid additional functions to use in recovery.
-
Hello
SELECT * FROM V$VERSION; BANNER Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production TNS for 32-bit Windows: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production
CREATE TABLE EMP ( DEPT_ID NUMBER, EMP_ID NUMBER, SALARY NUMBER );
Insert into EMP (DEPT_ID, EMP_ID, SALARY) Values (1, 1, 100); Insert into EMP (DEPT_ID, EMP_ID, SALARY) Values (1, 2, 200); Insert into EMP (DEPT_ID, EMP_ID, SALARY) Values (1, 3, 800); Insert into EMP (DEPT_ID, EMP_ID, SALARY) Values (2, 4, 100); Insert into EMP (DEPT_ID, EMP_ID, SALARY) Values (2, 5, 90); Insert into EMP (DEPT_ID, EMP_ID, SALARY) Values (3, 6, 200); Insert into EMP (DEPT_ID, EMP_ID, SALARY) Values (5, 7, 250); Insert into EMP (DEPT_ID, EMP_ID, SALARY) Values (4, 8, 150);
CREATE TABLE EMP_CONTACT(EMP_ID NUMBER, MOBILE_NO NUMBER); INSERT INTO EMP_CONTACT VALUES (1,9876543210); INSERT INTO EMP_CONTACT VALUES (1,8876543210); INSERT INTO EMP_CONTACT VALUES (1,7776543210); INSERT INTO EMP_CONTACT VALUES (2,6666543210); INSERT INTO EMP_CONTACT VALUES (2,5556543210);
I tried:
SELECT DEPT_ID, E.EMP_ID, MOBILE_NO FROM EMP E, EMP_CONTACT C WHERE E.EMP_ID = C.EMP_ID;
and got
DEPT_ID EMP_ID MOBILE_NO 1 1 7776543210 1 1 8876543210 1 1 9876543210 1 2 5556543210 1 2 6666543210
Output expected
DEPT_ID EMP_ID MOBILE_NO 1 1 7776543210 8876543210 9876543210 2 5556543210 6666543210 Please mark question as answered.
Kind regards
Sandeep M.
-
can I create an index on the column of duplicate lines?
Hello
I tried to create a unique index on an existing table, containing the duplicate lines.
I want to create an index of type everything on this column of duplicate rows.
If possible pls suggest me.
Kind regards
Vincent.Yes.
-
Remove the first line xml generated xml to VO
I am combining multiple xml files to generate the report using BIPublisher. I generated xml based on a VO by using VO.writeXML. How can I remove first row (<? xml version = "1.0"? >) in the xml file?Use the transformer and setOutputProperty to omit the first line.
Transformer transformer = TransformerFactory.newInstance () .newTransformer ();
transformer.setOutputProperty (OutputKeys.OMIT_XML_DECLARATION, 'yes');Edited by: Puthanampatti Dec. 6 2012 18:42
-
The Oracle answers and duplicate lines
Hello
I have a SQL view called "DUP" which shows all lines that are the same
for the 4 main fields INCNUM, TAKE, SAMP, CORR.
Now there are a few lines that are duplicates, whereas these 4 key column, BUT
There are also lines that are duplicates of 100%.
The Oracle answers seems to hide lines that are 100% (all columns, not only 4) duplicates. (there no SEPARATE in SQL).
How can I avoid this behavior?
Also how to create whole new second report showing 100% duplicates lines i.e.
who are the same for each unique column?
Thank you
metalrayYou just have to do the reverse then. Uncheck the separate support feature in the RPD and you will separate in your SQL
Thank you
Prash -
Get only the first line of duplicate data
Hello
I have the following situation...
I have a table called employees with column (object, name, function) where "re" is the primary key.
I import data within this table using an xml file, the problem is that some employees may be repeated inside this xml file, which means, I'll have repeated "re", and presents the columns is a primary key of my table.
To work around this problem, I created a table called employees_tmp that has the same built as employees, but without the primary key constraint, on this way I can import the XML inside the employees_tmp table.
What I need now is to copy that data employees_tmp used, but for cases where the "re" is taken, I just want to copy the first line found.
Just an example:
EMPLOYEES_TMP
---------------------
RE FUNCTION NAME
ANALYST GABRIEL 0987
MANAGER GABRIEL 0987
RANIERI ANALYST 0978
VICE PRESIDENT RICHARD 0875
I want to copy the data to employees looks like
EMPLOYEES
---------------------
RE FUNCTION NAME
ANALYST GABRIEL 0987
RANIERI ANALYST 0978
VICE PRESIDENT RICHARD 0875
How would I do that?
I really appreciate any help.
Thank youTry,
SELECT re, NAME, FUNCTION FROM (SELECT re, NAME, FUNCTION, ROW_NUMBER () OVER (PARTITION BY re ORDER BY NAME) rn FROM employees_tmp) WHERE rn = 1
G.
-
How to select records in the duplicate and two copies lines no rows
Hello
I'm working on Oracle with the following details
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64 bit Production
With partitioning, OLAP and Data Mining options
I need help to choose one of the duplicate records and a few duplicate not based on condition. I wrote the script that only gives me one of the record list duplicate, but I'm confused how select duplicate duplicates.
My condition is to select all records where TARGET TABLE AND TARGET_COLUMN IS NOT NULL. I need to select unique records of this this condition based on these attributes only Anwar. _
_ From the SOURCE
TARGET_TABLE TARGET_COLUMN SRC_COLUMN
-----
--------------------
-----
SRC_EXTERNAL SUBJECT_AREA SUBJECT_AREA
FISCAL_YEAR FISCAL_YEAR SRC_EXTERNAL
PARTY_ID_ORG PARTY_ALT_ID PARTY_ID
PARTY_ID_NEW PARTY_ALT_ID PARTY_ID
ESTABLISHMENT_NBR_ORG W2_EMPLOYER ESTABLISHMENT_NBR
ESTABLISHMENT_NBR_NEW W2_EMPLOYER ESTABLISHMENT_NBR
EMPLOYMENT_CODE_ORG W2_EMPLOYER EMPLOYMENT_CODE
EMPLOYMENT_CODE_NEW W2_EMPLOYER EMPLOYMENT_CODE
SICK_PAY_IND_ORG W2_EMPLOYER SICK_PAY_IND
SICK_PAY_IND_NEW W2_EMPLOYER SICK_PAY_IND
AGENT_IND_CODE
AGENT_FEIN
EMPLOYER_NAME
EMPLOYER_ADDRESS
CLIENT_ADDRESS
CITY
STATE
ZIP
_ REQUIRED TARGET
TARGET_TABLE TARGET_COLUMN SRC_COLUMN
-----
--------------------
-----
SICK_PAY_IND_NEW W2_EMPLOYER SICK_PAY_IND
EMPLOYMENT_CODE_NEW W2_EMPLOYER EMPLOYMENT_CODE
ESTABLISHMENT_NBR_NEW W2_EMPLOYER ESTABLISHMENT_NBR
PARTY_ID_NEW PARTY_ALT_ID PARTY_ID
SRC_EXTERNAL SUBJECT_AREA SUBJECT_AREA
FISCAL_YEAR FISCAL_YEAR SRC_EXTERNAL
MY QUERY_ +.
SELECT NOMFICHIER_SRC, TARGET_TABLE, SRC_COLUMN, TARGET_COLUMN
OF ITS_STAGE. STG_EDW_METADATA X
WHERE TARGET_TABLE IS NOT NULL AND TARGET_COLUMN IS NOT NULL
AND ROWID & gt; (SELECT MIN (ROWID)
OF ITS_STAGE. STG_EDW_METADATA Y
WHERE TARGET_TABLE IS NOT NULL AND TARGET_COLUMN IS NOT NULL
AND Y.TARGET_TABLE = X.TARGET_TABLE
AND Y.TARGET_COLUMN = X.TARGET_COLUMN)
MY RESULTS+ _
TARGET_TABLE TARGET_COLUMN SRC_COLUMN
-----
--------------------
-----
SICK_PAY_IND_NEW W2_EMPLOYER SICK_PAY_IND
EMPLOYMENT_CODE_NEW W2_EMPLOYER EMPLOYMENT_CODE
ESTABLISHMENT_NBR_NEW W2_EMPLOYER ESTABLISHMENT_NBR
PARTY_ID_NEW PARTY_ALT_ID PARTY_ID
Can some Oracle expert please help me solve this problem.
Thanks in advance
Rajesh
Published by: user532468 on 15 Sep, 2008 14:32With the help of
AND ROWID * > * (SELECT MIN (ROWID)
you select duplicates. Just change of
AND ROWID * = * (SELECT MIN (ROWID)
This will select everyring but duplicates. However, it is not effective. All you need is:
SELECT SRC_FILENAME,SRC_COLUMN,TARGET_TABLE, TARGET_COLUMN FROM (SELECT DISTINCT * FROM ITS_STAGE.STG_EDW_METADATA X WHERE TARGET_TABLE IS NOT NULL AND TARGET_COLUMN IS NOT NULL)
SY.
-
spell of the subject line in Windows Mail?
How can you out check the subject line in Windows Mail?
The subject line is omitted by using the spelling of WinMail. Way the easiest is to type the subject in the body of messages, check the spelling and then cut and paste it in the subject line. Bruce Hagen
MS - MVP October 1, 2004 ~ September 30, 2010
Imperial Beach, CA -
I have to remove the duplicate files, but having problems by selecting more than one file in the player at the time. How can I select multiple files at the same time so I can just delete them. I used to be able to do this in previous versions of Media Player, but this function seems now blocked or unavailable. The problem is this: through previous use of media player, it plays all my multimedia files several times whenever a device support has been added. He would try to save the files on my main drive, but since there is not enough room this would save the files somewhere else. This happened several times, I suppose, because when I upgraded my computer and a media scan was conducted he found duplicates of all my media various times of at least 6-8. I've consolidated since my plates on 3-disc multi to, but have now records duplicated hundreds and thousands of duplicate media files. Previous versions of Media Player would allow me to select all files and then delete them both of the reader, but also from my hard drive. So now I'm stuck with more than 300 GB of duplicate media I have to search line by line through all my hard drives to find each duplicate both, unless I can get media player to do what it can. Any help in this area would be appreciated.
Hello
1. did you of recent changes on the computer?
2. is Windows media player files in double creation during playback of music files?
To delete duplicate entries, click on another feature tab in the drive (for example the current playback), and then click library.
If this does not remove duplicates from your library, you can use the Add to library dialog box to search computer to analyze a file on your computer the duplicate entries not valid-pointing. The player will remove invalid entries in your library that point to files that no longer exist in the folder.Complete the steps above for files that are stored in the hard disks.
Method 1: Use the add to Library dialog box search for computers
(a) start Windows Media Player.
(b) press F3 on your keyboard to open Add to the library of the find computers dialog box.(c) click the Browse button to locate the folder on your computer so that your library contains invalid entries. Specify the location of the folder in the box look in.
If you are not sure what duplicate in your library entry is not valid, you can add a path column to display in your library. Specify the folder on your computer that corresponds to the path not valid file displayed in your library.
(d) click on the Search button.The player will search for digital media files and playlists in the folder that you specify and remove invalid entries in your library that point to files that no longer exist in the folder. If not valid in double entries point to other folders on your computer, repeat this procedure, specify a different folder every time.
If only a small number of duplicate entries exist, you can delete those invalid manually by right-clicking on the invalid entry, and then clicking Delete .
For large double-number of entries in your library (or if all your library is duplicated), it might be better to create a new library and delete the files.Method 2:
After you remove the duplicate entries, run the troubleshooting of Windows Media Library settings to solve this problem.
Open the troubleshooter in Windows Media Library
http://Windows.Microsoft.com/en-us/Windows7/open-the-Windows-Media-Player-library-Troubleshooter
Let us know the results.
I hope this helps.
-
Hello
I have a report that shows some of the duplicate records and need to eliminate duplicate rows on the report. How to hide the lines duplicated on the presentation of the report so that only 1 row appears on the report instead of having the same line appearing more than once? I use BI Publisher 11.1.1.7. Thank you.
It is advisable to eliminate duplicate rows to the data model, however, if you do not want to do it on the model please see below
Whereas you use RTF model
Change your for each tag to something like this
If you don't succeed; Thanks for posting your model and an example of xml data
Maybe you are looking for
-
possible to get the mails from the server?
Hello.One of my computers is down, I can't activate it now. I had all my correspondence of work on this (used Thunderbird, I don't remember exactly, but I'm afraid, I put the POP account here).So I used my other computer, installed Thunderbird here a
-
my brand new ipad 9.7 pro connects to itunes please help
It says "unusable ipad because it requires a newer version of itunes" but my mac has the latest updated. What should I do? I have everything backed up all my stuff from my ipad air 2 yesterday, but I can't get anything to transfer to the new ipad.
-
playing dvd or cd on tx2-1050ed
I have a touchsmart tx2-1050 ed but after 3 times going back to Hp it still has problems reading dvd or cd. During playback dvd mode full screen (in mediaplayer and dvd hp software to) display the (play/pause forward backward) bar jumps frequently as
-
LAN adapter is not recognized on Satellite L300
Hello My Satellite L300 do not recognize my network card, Wifi card is listed on the material management, but no LAN card. I checked in the BIOS it is activated. Thankx.
-
Problem call Matlab external function under Labview 7.1
Hello I have the problem when I want to call my m.file function in the script Matlab under Labview 7.1, that labview does not seem to be able to find this external Matlab function. I searched this forum, someone talked about setting search path in th