How to find the duplicate entries in column
clolum name descripitoin ex:
CLIENT_NAME | Last Name | First Name | Middle Name |suffix | Tendulkar Sachin Ramesh Jr.Sachin
| | Sachin Tendulkar Ramesh Jr.Sachin
| | Ramesh Sachin Tendulkar Jr.Sachin
PANno | no | AUBIU1966E
Address | Address of clint | Any address
Insert multiple records as per the e.g. shown in table. Write a oracle procedure in database schema to input the string and identify the possible duplicates from above table.
942919 wrote:
HI
but clint name is like
CLINT_NAME
Sachin Tendulkar Ramesh
Sachin Ramesh Tendulkar
Tendulkar Sachin Ramesh
in this senario clint name column show diffrent names
your query is not working
above three entries are same we need to find aboue three entries are duplicate1. Have one other column called Name2 in the table
2. scan the table and run the "combined" (means you combined every row from below separated by a space) the below output into name2 column
with t as (
select 'Sachin Tendulkar Ramesh' col from dual
select TRIM(substr (splitted,
instr (splitted, ' ', 1, level ) + 1,
instr (splitted, ' ', 1, level+1) - instr (splitted, ' ', 1, level) -1 )) as ret_row
from (select ' '||col||' ' splitted
from t)
connect by level <= length(splitted)-length(replace(splitted,' ',''))+1
and instr (splitted, ' ', 1, level+1) - instr (splitted, ' ', 1, level) -1 > 0 order by 1;
3. now run this
select name2,count(*)
the same like above but group by name2, then you will see it
Similar Messages
-
How to find the sum of a column
I need to find the sum of a column and use it in a different column. The following is the example.
Column names: Feedback(Good, Avg, Poor), Count(no of good, no of avg, no of poor) and %age(Feedback/sum(feedback))
I want to find the sum in Java class and also calculate the last column in java class.
Please tell me some way to do it.oh.. ok ..thanks for letting me know.. i will formulate the question in a proper way:
This is what my UI should look like:
Rating Count Percent
Excellent 2 20
Good 6 60
Poor 1 10
Bad 1 10
Now i have the following columns in the data base:
Meaning and feedback_rating.
So the following SQL Query:
SELECT hrl.meaning rating,
sum(decode(bcpi.feedback_rating, null, 0, 1)) counted
from cmp_cwb_person_info bcpi ,
hr_lookups hrl
group by hrl.meaning
will give me the result as
rating counted
Excellent 2
Good 6
Poor 1
Bad 1
Now I want a third column as percentage : Earlier we were doing this calculation in the sql query itself, so the query was like
SELECT hrl.meaning rating,
sum(decode(bcpi.feedback_rating, null, 0, 1)) counted,
sum(decode(bcpi.feedback_rating, null, 0, 1))/(max (select count (*) from cmp_cwb_person_info bcpi ,
hr_lookups hrl )) percent
from cmp_cwb_person_info bcpi ,
hr_lookups hrl
group by hrl.meaning
Hence the third column (percent) was calculated in the sql query itself.
But now i feel that the performance of the query could be improved if we get the first two columns from the database and the calculate the third column programatically in the java code.
So this is what I want to know. How can i do that? -
How to find the duplicate in the table
i have a table with the 3 columns
table name - employee
empcode firstname lastname
123 xyz pk
456 yzz pk
101 kkk jk
ALTER TABLE employee
ADD (CONSTRAINT employee_PK PRIMARY KEY
(empcode , firstname , lastname))
all the three columns make as porimary key, we are migrating the data there are issues with the data as the cobination of all the three resulting in duplicate, the last column is expected to have the duplicates but first two columns will not have the duplicate and one full row in the table (combintation will not have duplicates)
need a query find the duplicates for the full row validationAssuming that there may be other columns in the table;
with t as (
select 123 empcode, 'xyz' firstname, 'pk' lastname, 10 col4 from dual union all
select 456, 'yzz', 'pk', 20 from dual union all
select 456, 'yzz', 'pk', 30 from dual union all
select 101, 'kkk', 'jk', 40 from dual)
select empcode, firstname, lastname, col4
from (select t.*,
count(*) over(partition by empcode, firstname, lastname) num_rows
from t)
where num_rows > 1;
EMPCODE FIRSTNAME LASTNAME COL4
456 yzz pk 30
456 yzz pk 20 -
How to find the new tables and columns in a schema
hi..good morning to all...
I have a schema ABC which owns some objects.
Now some days before I have made another schema XYZ which was a replica of ABC schema.
between these days some new tables, new columns in the existing tables(with or without default value), comments on the columns are being added in the new schema i.e XYZ schema.
Now I have to find the extra things which are present in the new schema. I need to find the new tables, new columns in hte existing tables, their default values and descriptions of those.
Can u plss help me how can I find it?
I am guessing that I have to write a SQL query with a minus clause but I am not able to write it and also dont know where should I execute it.
plss help. thanks in advance.And moreover, when I am executing the query to get the desired result, then it is throwing "illegal use of long datatype" error and pointing to the b.data_default area of my query..
select a.table_name, a.column_name, b.data_default, a.comments from all_col_comments a, dba_tab_columns b
where a.TABLE_NAME=b.TABLE_NAME
and a.OWNER=b.OWNER
and a.OWNER=XYZ
minus
select c.table_name, c.column_name, d.data_default, c.comments from all_col_comments c, dba_tab_columns d
where c.TABLE_NAME=d.TABLE_NAME
and c.OWNER=d.OWNER
and c.OWNER='ABC'
order by 1, 2;
plss help... -
How to find the duplicate modifiers against the same SKU
Hi Gurus,
how to find he duplicate modifiers existing against the same SKU.
Any help or advise is helpful..
Thanks
Yasarhere is an example 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> -
How to find the difference of two columns in deski
Hi Everyone,
I have a deski report which is build from a single query. The report contains two tables.
Table-1:MTK Loc
MTKnet
Table-2:WTK Loc
WTKnet
Now i need to find the difference of the columns WTKnet and MTKnet.
These two are report level variables.Their definitins are as below:
MTKnet:=Sum((<Fees Collected by Per Collected>) In Body) ForEach <vMTKLocation>
WTKnet:=Sum((<Fees Collected by Per Collected>) In Body) ForEach <vWTKLocation>
Where <Fees Collected by Per Collected> is universe variable.
Please help...
Thanks in Advance......Hi Bol,
As I understand you are taking MTK_Loc and WTK_Loc together in the report which have common values under Fees Collected by Per Collected column.
Please follow the steps mentioned below:
1. Calculate the Variables MTK_Net as
=Sum(<Fees>) IN <MTK_Loc>
2. Calculate the Variables WTK_Net as
=Sum(<Fees>) IN <WTK_Loc>
3. You will get the values based on the Locations MTK_Loc and WTK_Loc .
You are using combination of values for MTK_Loc and WTK_Loc hence you will get the variable values in combination.
Insert new column right to the WTK_Net and write the formula name it Variance.
=<MTK_Net>- <WTK_Net>
The values look like :
MTK_Loc WTK_Loc MTK_Net WTK_Net Variance
Chicago Chicago 16,696,274.43 157,168.26 16,539,106.17
Chicago Madison 16,696,274.43 274,396.12 16,421,878.31
Chicago Milvaki 16,696,274.43 16,622,870.97 73,403.46
Chicago Pennsylvania 16,696,274.43 4,299.35 16,691,975.08
Chicago Waukesha 16,696,274.43 22,067.08 16,674,207.35
Here you will see values for MTK_Net are repeated because these are based on the MTK_Loc which is same for all rows i.e. Chicago , same is the case with remaining values of MTK_Loc.
We can not calculate variabnce based on the values like Canada,Pennsylvania for all values as these values come in combination of each other and as these are all connected columns WEBI groups Measure data based on the Dimension and variable columns associated with it.
MTK_Loc WTK_Loc MTK_Net WTK_Net Variance.
Chicago Chicago 16696274.43 157168.26 16539106.17
However you can compare the values based on the values as :
1. Drag and Drop MTK_Loc and MTK_Loc separately on the report.
2. Drag and Drop WTK_Loc and WTK_Loc separately and put it on the report, Connect it to the columns MTK_Loc and MTK_Loc columns already dragged. Then you can compare the values
MTK_Loc MTK_Net WTK_LOC WTK_Net
Chicago 16,696,274.43 Chicago 157,168.26
Madison 315,705.91 Madison 274,396.12
Manitowoc 362,632.50 Manitowoc 359,978.50
Milvaki 54,172.84 Milvaki 16,622,870.97
Pennsylvania 2,966.56 Pennsylvania 4,299.35
Waukesha 9,028.03 Waukesha 22,067.08
Here I unchecked the option avoid duplicate row aggregation (select table-> format table) thatu2019s why it is showing all values as a sum of all MTK_Net and WTK_Net values corresponding to Location values..
Here we are using MTK_Loc and WTK_Loc separately and not connected because though values seems same but they are used in combination ( Chicago, Pennsylvania) in 2 separate tables in DB hence we canu2019t synchronize them by liking these 2 location columns using 2 data providers.
I Hope this is what you want....
Thanks....
Pratik -
How to find the Different entries of the characters.
HI Gurus,
i have two characters in the Cube, for these two characters text is same for some records and different for some records. My requirement i need to find out the records whose text values are different for these two characters. I need to find out these records in the report level. Please guide me the way to find out a solution for this issue.
Thank you very much in advance
James
Message was edited by:
james winsletHi ,
I want the Report like this.
TransactionID--Usersite-Custsales
10001--newyork1newyork2
10002--newyork3newyork5.
10003--newyork6newyork6.
In above report I Do not want the 3rd row because in that one the two characteristics text's are equal.
I want the final report as
TransactionID--Usersite-Custsales
10001--newyork1newyork2
10002--newyork3newyork5.
Thanks,
James -
How to find the column name and table name with a value
Hi All
How to find the column name and table name with "Value".
For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
Any help is highly appricatable
Thanks & Regards
Srikkanth.M2 solutions by Michaels (the latter is 11g upwards only)...
michaels> var val varchar2(5)
michaels> exec :val := 'as'
PL/SQL procedure successfully completed.
michaels> select distinct substr (:val, 1, 11) "Searchword",
substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from cols,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || :val
|| '%'')'
).extract ('ROWSET/ROW/*')
) t
-- where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
order by "Table"or
SQL> select table_name,
column_name,
:search_string search_string,
result
from cols,
xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
columns result varchar2(10) path '.'
where table_name in ('EMP', 'DEPT')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME ES RESEARCH
DEPT DNAME ES SALES
EMP ENAME ES JONES
EMP ENAME ES JAMES
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES PRESIDENT
EMP JOB ES SALESMAN
9 rows selected. -
Hi,
I am having a entire road network of NA in Oracle Spatial as SDO geometry. I used to connect this db using arcmap through arcsde. When I use the Identity tool on Interstates, I am getting 3 records as output.
I tried to use SDO_NN_DISTANCE(1) with a distance of 200 feet. I am getting two or three rows, SDO_NN_DISTANCE(1) as dist provides the same distance for two or three rows. Each row represents the same road segment with their alternative names.
How to find the duplicates in Oracle Spatial.
Thanks
Vadivelan. PHi Vadivelan,
Identifying duplicate geometries is a common requirement in Oracle Spatial. Rather than repeat previous advice given on this forum, I think its best to point you in the direction of the search results:
http://forums.oracle.com/forums/search.jspa?threadID=&q=duplicates&objID=f76&dateRange=all&userID=&numResults=15&rankBy=10001
Regards,
John -
Most all of my 1700 songs have been duplicated in iTunes. I have downloaded the instructions how to delete the duplicates but it says "sort by the date you added" and i have no column that says that. I am running windows xp.
Apple's official advice is here... HT2905 - How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls.
Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created. If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin.
Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See this thread for background and please take note of the warning to backup your library before deduping.
(If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
tt2 -
How to find the number of entries in a master data table
Hi Experts,
I am trying to find the entries in 0CUSTOMER master data.
BW>LISTCUBE>Data target: 0CUSTOMER and selected the fields that I need.
I would like to know how to find the "number of entrees". I tried to run the SUM for a count field, but it is taking forever as there are huge number of records .Hi Dev,
Go to the change/display mode of the info object (0CUSTOMER) in your case. Go to the Master data/Text tab. Here you will find the master data tables according to your settings (P orQ or X or Y). Double click on the table name and it will take you to the SE11 display. From there, you can check the number of records as you do in any transparent table.
Hope this helps.
Thanks and Regards
Subray Hegde -
How to find the number of columns in an internal table DYNAMICALLY ?
Hi,
How to find the number of columns in an internal table DYNAMICALLY ?
Thanks and Regards,
saleem.Hi,
you can find the number of columns and their order using
the <b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = sy-repid
changing
ct_fieldcat = IT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif
now describe your fieldcat . and find no of columns.
and their order also..
regards
vijay -
How to restrict the duplicate values in lov column of VO based Adv Table
Hi Gurus,
I want to restrict the duplicate values at lov which is a colunm in an Adv Table.
If user enters duplicate values then first it should show an error msg that Duplicate values have been entered.
After the duplicate values have been removed, then the user can save all the values in the table.
My Adv Table is based on a VO.
The link how to restrict the duplicate values at form level
talks about Adv Table based on a EoVO, which doesnot work in my case.
My Approach,
I am iterating through RowSetIterator and committing through PROCEDURE.
I am able to avoid duplicate entry through a function checkRespId. (given below)
Below code is for iterating and committing.
public void saveline(String reqid,String userid)
System.out.println("RequestId/saveline"+reqid);
System.out.println("UserId/saveline"+userid);
OAViewObject vo = (OAViewObject)getRespLineVO1();
RespLineVORowImpl row = null;
int fetchedRowCount = vo.getFetchedRowCount();
RowSetIterator deleteIter = vo.createRowSetIterator("deleteIter");
if (fetchedRowCount > 0)
deleteIter.setRangeStart(0);
deleteIter.setRangeSize(fetchedRowCount);
for (int i = 0; i < fetchedRowCount; i++)
System.out.println("Inside the for LOOP");
row = (RespLineVORowImpl)deleteIter.getRowAtRangeIndex(i);
String respoidid = row.getAttribute("ResponsibilityId")+"";
String respname = row.getAttribute("ResponsibilityName")+"";
String stdate = row.getAttribute("StartDate")+"";
String enddate = row.getAttribute("EndDate")+"";
String linestatus ="A";
if(userid!=null)
if(!(respoidid.equals("null")) && respoidid!=null)
String checkingrespid=null;
checkingrespid = checkRespId(userid,respoidid);+contains no if not duplicate and yes if its duplicate+
System.out.println("checkingrespid for Resp with ID :"+respoidid+"exists or not "+checkingrespid);
if(checkingrespid.equals("No"))
String message, result = null;
Connection txn = getOADBTransaction().getJdbcConnection();
try
calling PROC ...
catch(Exception e)
message = "Error in Inserting into line" + e;
throw new OAException(message, OAException.ERROR);
else
throw new OAException("You have entered duplicate no. of values", OAException.ERROR);
else
System.out.println("respoidid is null");
break;
deleteIter.closeRowSetIterator();
public String checkRespId(String userid,String respoidid)
String createRow="No";
OAViewObject vo = (OAViewObject)findViewObject("CheckRespVO1");
if (vo != null)
vo.setWhereClauseParams(null);
vo.setWhereClauseParam(0, userid);
vo.setWhereClauseParam(1, respoidid);
vo.executeQuery();
System.out.println("ROW COUNT IS "+vo.getRowCount());
if(vo.getRowCount()>0)
createRow="Yes";
else
createRow="No";
return createRow;
Problem:
I remove the duplicate entries and click on save and get this error.
Unable to perform transaction on the record. \nCause: The record contains stale data. The record has been modified by another user.
\nAction: Cancel the transaction and re-query the record to get the new data.
Thanks,
SombitHi Anil,
I am trying out your code but stuck in inserting the rows
using your code in URL: http://oracleanil.blogspot.com/2010/09/oaf-passing-table-type-object-to-oracle.html
I am always getting the same exception i.e COde blast in when I run.
My modified code is:
String[] as = null;
Number[] vNumber = null;
Number[] vNumberrespid = null;
Number reqidnumber = null;
reqidnumber = new Number(Integer.parseInt(reqid));
Connection txn = getOADBTransaction().getJdbcConnection();
String mCreateSearchRequestStatement = null;
OAViewObject vo = (OAViewObject)findViewObject("RespLineVO1");
int j = vo.getFetchedRowCount();
try
System.out.println("abouce try");
vo.reset();
if (vo.getFetchedRowCount() > 0)
System.out.println(String.valueOf("Fetched row count ").concat(String.valueOf(vo.getFetchedRowCount())));
int i = 0;
as = new String[j];
vNumber = new Number[j];
vNumberrespid = new Number[j];
while (vo.hasNext())
vo.next();
System.out.println(String.valueOf("Inisde the do while loop").concat(String.valueOf(i)));
vNumber[i] = (reqidnumber);
vNumberrespid = ((Number)vo.getCurrentRow().getAttribute("ResponsibilityId"));
as[i] = String.valueOf(vo.getCurrentRow().getAttribute("ResponsibilityName")).concat(String.valueOf(""));
System.out.println("Request ID "+reqidnumber[i]);//getting null even there is some value selected
System.out.println("ResponsibilityId "+vNumberrespid[i]);//getting null even there is some value selected
System.out.println("Resp Name "+as[i] );//getting null even there is some value selected
i++;
CallableStatement cs = txn.prepareCall("{call XX_PassTableType.XX_PassTableType_prc(:1, :2,:3)}");
ARRAY array = new ARRAY(new ArrayDescriptor("APPS.JTF_NUMBER_TABLE", txn), txn, vNumber);
ARRAY arraynew = new ARRAY(new ArrayDescriptor("APPS.JTF_NUMBER_TABLE", txn), txn, vNumberrespid);
ARRAY array1 = new ARRAY(new ArrayDescriptor("APPS.JTF_VARCHAR2_TABLE_100", txn), txn, as);
cs.setArray(1, array);
cs.setArray(2, arraynew);
cs.setArray(3, array1);
cs.registerOutParameter(3, 2003, "JTF_VARCHAR2_TABLE_100");
cs.execute();
ARRAY error = null;
error = (ARRAY)cs.getArray(2);
if ((error != null) && (error.length() > 0))
System.out.println(String.valueOf("Error is ").concat(String.valueOf(error.getArray())));
String[] retError = new String[j];
retError = (String[])error.getArray();
System.out.println(String.valueOf("Error in saving data").concat(String.valueOf(retError[0])));
cs.close();
catch (Exception exception)
throw new OAException("code blast", OAException.ERROR);
Thanks,
Sombit -
How to find the Data Type of a column
Dear All,
How to find the Data Type of a Column dynamically in oracle Form.
Thanks and Regards,
Fazil
Edited by: user11334489 on Aug 25, 2012 9:06 PMhi,
you can use get_item_property built-in
eg:
declare
l_item VARCHAR2(10);
begin
l_item := Get_Item_Property('item_name',DATATYPE);
end; -
How to find the Date and Time of Modification of Column in aTable?
Hi all,
Do you know how to find the Date and Time of Addition of Column to a Particular Table?.
I know however, How to find the modification time of the Table. Using the below Query :
Select Object_Name, to_Char(Last_DDL_TIME, 'DD-Mon-YYYY HH24:MI:SS') Last_DDL from User_Objects where Object_Type = 'TABLE';
Object_Name
Last_DDL
Employee
20-Aug-2013 09:23:03
I wanted to know the Creation or Modification Date and Timestamp of all columns of Employee Table?. Is it possible at all. If possible, How to get it?.
Regards,
Bhaskar MI agree with you on that. Since its a development enviornment I can remove the column but that not my point here.
My whole purpose it to know whether we get the Column's Creation or Modification DateTime.
Maybe you are looking for
-
Ctrl/Alt Keys not Working in Parallels
Hi, I'm running Illustrator CS6 using Parallels Desktop 8 and Windows 7. It appears that the ctrl/alt keys do not work. Has anyone found a solution? I've tried resetting my preferences and restarting my computer. Any help would be greatly appreciaed.
-
KDE: Xorg 1.8 and synaptics [SOLVED]
Hi, It appears that the synaptiks package from AUR works just fine with the default /etc/X11/xorg.conf.d/10-synaptics.conf. I just had to check System Settings->Keyboard & Mouse->Touchpad->Touchpad Configuration->Scrolling boxes in order to get my sc
-
Question about ex println.
Marry christmas all. prepare for a stupid question. After a look in API I see 10 PrintStream.println() all with diffrent arguments. So for example I can do . System.out.println("A simple String); System.out.println(120)And the method with the rigth a
-
Optimal settings for export from 1080p camcorder - Canon HF100
I just bought an HF100 camcorder. When I make projects with iMovie what are best export settings for 1080p projects? What about for 480p for a DVD. I tried to export 1080p video and it looks grainy. I'm not sure if this is the fault of the camera or
-
Master Data Attributes not showing in InfoCube
Hi Experts, I'm a little lost here. I have loaded the master data for a field ZPARTY(data coming from 3 non-SAP sources S1, S2 and S3) with all its attributes. I have actovated it and I see it as well in the BEx. Now I have loaded related Transacti