Selecting duplicate values
I have a table called AADETAILS with two colums ('Name' and 'ID').
The ID column is not supposed to have any duplicates, so I need a query that returns a list of all the duplicate ID's (with their Name). For example, if there is an ID with a value of 123 duplicated three times and an ID with a value of 456 duplicated four times, I need a list of the Name and ID of the three instances of 123 and the four instances of 456.
I have the following :
SELECT Name, ID
FROM AADETAILS
GROUP BY Name, ID
HAVING COUNT(ID) > 1
its not returning anything, but it should (I can see the duplicates in the table if I view all the data in it), whats wrong with that query ?
Thanks
its simple, try this
select name, id from aadetails a
where rowid>=(select min(rowid) from aadetails b where a.id=b.id)
or
select name, id from aadetails a
where rowid>(select min(rowid) from aadetails b where a.id>=b.id)
(due to lake of data, solution given on the basis of Trial n Error. so it might be wrong solution)
hopes it will work,
thanks,
Mahesh
Similar Messages
-
Select List to check duplicate values before putting into another item
Hi All ,
I have a select list which contains .. country regions like ( APAC , EMEA etc ) .
When I select any region , all the countries belonging to the region fills in another item .
Suppose I select APAC , all the countries like India , Japan etc all fills in another item .
But the problem is , if I select twice APAC , it fills duplicate values . Its filling duplicate values .
I want to put validation or check for country value ...
Suppose I select ' APAC ' it fills all APAC countries in another item . Now Again If I select APAC then it first check the item whether the country is there or not . If already APAC countries are there in the Item then it will show an error message that " Value already Exist ' .
I am not able to fix this problem . it is creating duplicate values in database table .
Please some one help me on this ..
Thanks
PrashantPatrick ,
Sorry , I am correcting my words ..
I am using Multiselect List ( P11_REGION) having regions APAC , EMEA , LAD etc .
When I select Region like APAC , it fills all the countries of APAC and puts into a List .
If again I select APAC , it again fills all the APAC countries and puts into a list which causes duplicacy .
I have one Application Process which returns Country according to Region selection and puts in the list .
So , what i want is when user twice selects region APAC , it searches the list whether APAC countries are there or not . If countries are already exists then it show an error otherwise Puts the countries in the list . -
How can i select the duplicate values
Hi experts ,
how can i find the duplicate values from the table. i want to display the all duplicate the rows.
1. Table Structure :-
CREATE TABLE CIF_MIGRATE
LINE_NO NUMBER(10),
ACCT_NO VARCHAR2(20 BYTE),
BRANCH_ID VARCHAR2(1 BYTE),
CUSTOMER_NAME VARCHAR2(100 BYTE),
FATHER_NAME VARCHAR2(100 BYTE),
GF_NAME VARCHAR2(100 BYTE),
TOTAL VARCHAR2(100 BYTE),
STATUS VARCHAR2(100 BYTE),
CUSTOMER_TYPE VARCHAR2(10 BYTE),
GENDER VARCHAR2(10 BYTE)
) 2. Sample Data:-
SET DEFINE OFF;
Insert into CIF_MIGRATE
(LINE_NO, BRANCH_ID, CUSTOMER_NAME, CUSTOMER_TYPE)
Values
(72, '1', 'Addis Belay Construction Material Rental', 'C');
Insert into CIF_MIGRATE
(LINE_NO, BRANCH_ID, CUSTOMER_NAME, CUSTOMER_TYPE)
Values
(73, '1', 'Addis Belay Construction Material Rental', 'C');
SET DEFINE OFF;
Insert into CIF_MIGRATE
(LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, CUSTOMER_TYPE, GENDER)
Values
(2869, '1', 'Abraham', 'Fiseha',
'I', 'Male');
Insert into CIF_MIGRATE
(LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, CUSTOMER_TYPE, GENDER)
Values
(2870, '9', 'Abraham', 'Fiseha',
'I', 'Male');
Insert into CIF_MIGRATE
(LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, GF_NAME, CUSTOMER_TYPE, GENDER)
Values
(2872, '9', 'Abraham', 'Baraki',
'Medehniye', 'I', 'Female');
Insert into CIF_MIGRATE
(LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, GF_NAME, CUSTOMER_TYPE, GENDER)
Values
(2873, '1', 'Abraham', 'Geber kirstos',
'gebre medihin', 'I', 'Female');
Insert into CIF_MIGRATE
(LINE_NO, BRANCH_ID, CUSTOMER_NAME, FATHER_NAME, GF_NAME, CUSTOMER_TYPE)
Values
(2874, '1', 'Abraham', 'Gebre egziabher',
'Negussie', 'I');
COMMIT;4. My requirement is i need display all the duplication customer
CUSTOMER_NAME FATHER_NAME,GF_NAME
Addis Belay Construction Material Rental
Addis Belay Construction Material Rental
Abraham Fiseha
Abraham Fiseha5. I tried below query but i cant reach what i want exactly
SELECT CUSTOMER_NAME,FATHER_NAME,GF_NAME
FROM CIF_MIGRATE
GROUP BY CUSTOMER_NAME,FATHER_NAME,GF_NAME
HAVING COUNT (*) > 1kindly suggest me the solution
Thanks
ArunHi,
You're on the right track using COUNT (*), but, for this job, you want the analytic COUNT, not the aggregate COUNT.
"GROUP BY x, y, z" means that the result set will only contain 1 row for each distinct combination of x, y and z. Most aggregate functions (including COUNT) have analytic counterparts that get the same results without reducing the number of rows.
Here's one way you can use the analytic COUNT function:
WITH got_cnt AS
SELECT customer_name
, father_name
, gf_name
, COUNT (*) OVER ( PARTITION BY customer_name
, father_name
, gf_name
) AS cnt
FROM cif_migrate
SELECT customer_name
, father_name
, gf_name
FROM got_cnt
WHERE cnt > 1
;PARTITION BY in analytic functions corresponds to GROUP BY in aggregate functions. -
Avoiding null and duplicate values using model clause
Hi,
I am trying to use model clause to get comma seperated list of data : following is the scenario:
testuser>select * from test1;
ID VALUE
1 Value1
2 Value2
3 Value3
4 Value4
5 Value4
6
7 value5
8
8 rows selected.
the query I have is:
testuser>with src as (
2 select distinct id,value
3 from test1
4 ),
5 t as (
6 select distinct substr(value,2) value
7 from src
8 model
9 ignore nav
10 dimension by (id)
11 measures (cast(value as varchar2(100)) value)
12 rules
13 (
14 value[any] order by id =
15 value[cv()-1] || ',' || value[cv()]
16 )
17 )
18 select max(value) oneline
19 from t;
ONELINE
Value1,Value2,Value3,Value4,Value4,,value5,
what I find is that this query has duplicate value and null (',,') coming in as data has null and duplicate value. Is there a way i can avoid the null and the duplicate values in the query output?
thanks,
Edited by: orausern on Feb 19, 2010 5:05 AMHi,
Try this code.
with
t as ( select substr(value,2)value,ind
from test1
model
ignore nav
dimension by (id)
measures (cast(value as varchar2(100)) value, 0 ind)
rules
( ind[any]= instr(value[cv()-1],value[cv()]),
value[any] order by id = value[cv()-1] || CASE WHEN value[cv()] IS NOT NULL
and ind[cv()]=0 THEN ',' || value[cv()] END
select max(value) oneline
from t;
SQL> select * from test1;
ID VALUE
1 Value1
2 Value2
3 Value3
4 Value4
5 Value4
6
7 value5
8
8 ligne(s) sélectionnée(s).
SQL> with
2 t as ( select substr(value,2)value,ind
3 from test1
4 model
5 ignore nav
6 dimension by (id)
7 measures (cast(value as varchar2(100)) value, 0 ind)
8 rules
9 ( ind[any]= instr(value[cv()-1],value[cv()]),
10 value[any] order by id = value[cv()-1] || CASE WHEN value[cv()] IS NOT NULL
11 and ind[cv()]=0 THEN ',' || value[cv()] END
12 )
13 )
14 select max(value) oneline
15 from t;
ONELINE
Value1,Value2,Value3,Value4,value5
SQL> -
Unable to Enforce Unique Values, Duplicate Values Exist
I have list in SP 2010, it contains roughly 1000 items. I would like to enforce unique values on the title field. I started by cleaning up the list, ensuring that all items already had a unique value. To help with this, I used the export
to excel action, then highlight duplicates within Excel. So as far as I can tell, there are no duplicates within that list column.
However, when I try to enable the option to Enforce Unique Values, I receive the error that duplicate values exist within the field and must be removed.
Steps I've taken so far to identify / resolve duplicate values:
- Multiple exports to Excel from an unfiltered list view, then using highlight duplicates feature > no duplicates found
- deleted ALL versions of every item from the list (except current), ensured they were completely removed by deleting from both site and site collection recycle bins
- Using the SP Powershell console, grabbed all list items and exported all of the "Title" type fields (Item object Title, LinkTitle, LinkTitleNoMenu, etc) to a csv and ran that through excel duplicate checking as well.
Unless there's some rediculous hidden field value that MS expects anyone capable of attempting to enforce unique values on a list (which is simple enough for anyone to figure out - if it doesn't throw an error), then I've exhausted anything I can think
of that might cause the list to report duplicate values for that field.
While I wait to see if someone else has an idea, I'm also going to see what happens if I wipe the Crawl Index and start it from scratch.
- JonFirst, I create index for a column in list settings, it works fine no matter duplicate value exists or not;
then I set enforce unique values in the field, after click OK, I get duplicate values error message.
With SQL Server profiler, I find the call to proc_CheckIfExistingFieldHasDuplicateValues and the parameters. After reviewing this stored procedure in content database,
I create the following script in SQL Server management studio:
declare @siteid
uniqueidentifier
declare @webid
uniqueidentifier
declare @listid
uniqueidentifier
declare @fieldid
uniqueidentifier
set @siteid='F7C40DC9-E5D3-42D7-BE60-09B94FD67BEF'
set @webid='17F02240-CE04-4487-B961-0482B30DDA84'
set @listid='B349AF8D-7238-419D-B6C4-D88194A57EA7'
set @fieldid='195A78AC-FC52-4212-A72B-D03144DC1E24'
SELECT
* FROM TVF_UserData_List(@ListId)
AS U1 INNER
MERGE JOIN
NameValuePair_Latin1_General_CI_AS
AS NVP1 WITH (INDEX=NameValuePair_Latin1_General_CI_AS_MatchUserData)
ON NVP1.ListId
= @ListId AND NVP1.ItemId
= U1.tp_Id
AND ((NVP1.Level
= 1 AND U1.tp_DraftOwnerId
IS NULL)
OR NVP1.Level
= 2)
AND NOT((DATALENGTH(ISNULL(NVP1.Value,
= 0)) AND U1.tp_Level
= NVP1.Level
AND U1.tp_IsCurrentVersion
= CONVERT(bit, 1)
AND U1.tp_CalculatedVersion
= 0 AND U1.tp_RowOrdinal
= 0 INNER
MERGE JOIN
NameValuePair_Latin1_General_CI_AS
AS NVP2 WITH (INDEX=NameValuePair_Latin1_General_CI_AS_CI)
ON NVP2.SiteId
= @SiteId AND NVP2.ListId
= @ListId AND NVP2.FieldId
= @FieldId AND NVP2.Value
= NVP1.Value
AND NVP2.ItemId <> NVP1.ItemId
CROSS APPLY TVF_UserData_ListItemLevelRow(NVP2.ListId, NVP2.ItemId,
NVP2.Level, 0)
AS U2 WHERE ((NVP2.Level
= 1 AND U2.tp_DraftOwnerId
IS NULL)
OR NVP2.Level
= 2)
AND NOT((DATALENGTH(ISNULL(NVP2.Value,
= 0))
I can find the duplicate list items based on the result returned by the query above.
Note that you need to change the parameter values accordingly, and change the name of NameValuePair_Latin1_General1_CI_AS table based on the last parameter of the
proc_CheckIfExistingFieldHasDuplicateValues stored procedure. You can review the code of this stored procedure by yourself.
Note that direct operation on the content database in production environment is not supported, please do all these in test environment. -
Need help-SQL with result format suppressing duplicate values
I am trying to write a SQL which would select data from the below tables(in reality i have many other tables also) but I wanted to know how do i get the data in the format given below.
The scenario is :-A training_plan can N no. of OBJECTIVES and EACH objective has N no.of activities
Insert into TEST_TRAINING_PLAN
(TPLAN_ID, TPLAN_NAME, TPLAN_DESC, T_PERSON_ID
Values
('111', 'test_name', 'test_name_desc', '****')
Objectives table:-
Insert into TEST_TRAINING_OBJECTIVE
(T_OBJECTIVE_ID, T_OBJECTIVE_NAME,T_owner)
Values
('10', 'objective1', '1862188559')
Objective and Training Plan relationship table where TPLAN_ID is the foreign key.
Insert into TEST_TP_OBJECTIVE
(TPLAN_TOBJ_ID, TPLAN_ID, T_OBJECTIVE_ID,
REQUIRED_CREDITS)
Values
('1', '111', '10',5)
Objective and Activity relationship table where T_OBJECTIVE_ID is the foreign key from the TEST_TRAINING_OBJECTIVE table.
Insert into TEST_TRAIN_OBJ_ACTIVITY
(TOBJ_TRAIN_ACTIVITY, T_OBJECTIVE_ID, ACTIVITY_ID, IS_REQUIRED, STATUS,
ACTIVITY_TYPE, ITEM_ORDER, IS_PREFERRED)
Values
('1000', '10', 'selfstudy event', SS1, NULL,
'Event', 0, 0);
Insert into TEST_TRAIN_OBJ_ACTIVITY
(TOBJ_TRAIN_ACTIVITY, T_OBJECTIVE_ID, ACTIVITY_ID, IS_REQUIRED, STATUS,
ACTIVITY_TYPE, ITEM_ORDER, IS_PREFERRED)
Values
('1001', '10', 'SQLcourse', 1, NULL,
'Course', 1, 0);
Insert into TEST_TRAIN_OBJ_ACTIVITY
(TOBJ_TRAIN_ACTIVITY, T_OBJECTIVE_ID, ACTIVITY_ID, IS_REQUIRED, STATUS,
ACTIVITY_TYPE, ITEM_ORDER, IS_PREFERRED)
Values
('1002', '10', 'testSQL', 1, NULL,
'test', 2, 0);
COMMIT;
firstname emplid Tplan name Number of activities/credits completed(for TP) Objective Name Number of required activities/Credits (for objective) Number of activities/credits completed(for objective) activity name activity completion status
U1 U1 TP1 5
OBJ1 4 3 C1 PASSED
C2 PASSED
C3 WAIVED
T1 ENROLLED
T2 ENROLLED
OBJ2 3 2
S1 ENROLLED
S2 PASSED
T3 WAIVED
U1 U1 TP2 C4 INPROGRESS
50 OBJ11 50 30 C11 PASSED
**The second row where we have another training_plan record and accordingly all objectivesand their objective.**similarly ,i need to display many Training_plan records in such tabular format.Please help with the SQL query to select and display data in the above format
If you want to suppress duplicate values in some of your results columns
I am using toad 9.1 using Oracle 10g version 2Hi,
You can use the BREAK command to suppress duplicate values.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12009.htm#SQPUG030
(scroll down for an example)
It's a 'SQL*Plus-ism', not sure if TOAD's capable to handle it.
Simple example:
HR%xe> break on department_name
HR%xe> select l.department_name
2 , e.last_name
3 , e.first_name
4 from departments l
5 , employees e
6 where e.department_id = l.department_id;
DEPARTMENT_NAME LAST_NAME FIRST_NAME
Executive King Steven
Kochhar Neena
De Haan Lex
IT Hunold Alexander
Ernst Bruce
Austin David
Pataballa Valli
Lorentz Diana
Finance Greenberg Nancy
Faviet Daniel
Chen John
Sciarra Ismael
Urman Jose Manuel
Popp Luis
Purchasing Raphaely Den
Khoo Alexander
Baida Shelli
Tobias Sigal
Himuro Guy
Colmenares Karen
Shipping Weiss Matthew
Fripp Adam
Kaufling Payam
Vollman Shanta
Mourgos Kevin
Nayer Julia
Mikkilineni Irene
Landry James
Public Relations Baer Hermann
Accounting Higgins Shelley
Gietz William
106 rijen zijn geselecteerd. -
i have one database table called "sms1" that table is updated every day or on daily basis it has the following fields in it:
SQL> desc sms1;
Name Null? Type
MOBILE NUMBER
RCSTCNATCNATCNATCNAWTHER VARCHAR2(39 CHAR)
SNO NUMBER
INDATE DATE
From this table the is one column "RCSTCNATCNATCNATCNAWTHER VARCHAR2(39 CHAR)" . I am splitting it into different columns like :
SQL> desc smssplit;
Name Null? Type
R VARCHAR2(2 CHAR)
C VARCHAR2(2 CHAR)
S VARCHAR2(1 CHAR)
TC VARCHAR2(3 CHAR)
NA VARCHAR2(3 CHAR)
TC2 VARCHAR2(3 CHAR)
NA2 VARCHAR2(3 CHAR)
TC3 VARCHAR2(3 CHAR)
NA3 VARCHAR2(3 CHAR)
TC4 VARCHAR2(3 CHAR)
NA4 VARCHAR2(3 CHAR)
WTHER VARCHAR2(10 CHAR)
SNO NUMBER
INSERTDATA VARCHAR2(25 CHAR)
Now I am written a procedure to insert the data from "Sms1" table to smssplit table...
CREATE OR REPLACE PROCEDURE SPLITSMS
AS
BEGIN
INSERT INTO scott.SMSSPLIT ( R,C,S,TC,NA,TC2,NA2,TC3,NA3,TC4,NA4,WTHER,SNO)
SELECT SUBSTR(RCSTCNATCNATCNATCNAWTHER,1,2) R,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,3,2) C,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,5,1) S,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,6,3) TC,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,9,3) NA,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,12,3) TC2,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,15,3) NA2,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,18,3) TC3,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,21,3) NA3,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,24,3) TC4,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,27,3) NA4,
SUBSTR(RCSTCNATCNATCNATCNAWTHER,30,10) WTHER, SNO
FROM scott.SMS1 where SNO=(select MAX (sno) from SMS1);
END;
Now in order to update the second table with data from first table on regular basis I have written a job scheduler and I am using oracle 9.0. version...
DECLARE
X NUMBER;
JobNumber NUMBER;
BEGIN
SYS.DBMS_JOB.SUBMIT
job => X
,what => 'scott.SPLITSMS;'
,next_date => SYSDATE+1/1440
,interval => 'SYSDATE+1/1440 '
,no_parse => FALSE
:JobNumber := to_char(X);
END;
Now this job scheduler is working properly and updating the data for every one minute but it is taking or updating the duplicate values also ..like example:
R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
INSERTDATA
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:49:16
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:49:16
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:50:17
R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
INSERTDATA
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:50:17
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:51:19
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:51:19
R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
INSERTDATA
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:52:20
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:52:20
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:53:22
R C S TC NA TC2 NA2 TC3 NA3 TC4 NA4 WTHER SNO
INSERTDATA
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:53:22
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:54:45
33 35 2 123 456 789 543 241 643 243 135 RRRRRR 55
06-SEP-2012 03:54:45
Now I do not want the duplicate values to be updated ...and want them to ignore them.....
please I need a help on this query........How to avoid the duplicate values............Look at the posts closely:might not be needed if formatted ;)
create or replace procedure splitsms as
begin
insert into scott.smssplit (r,c,s,tc,na,tc2,na2,tc3,na3,tc4,na4,wther,sno)
select substr(rcstcnatcnatcnatcnawther,1,2) r,
substr(rcstcnatcnatcnatcnawther,3,2) c,
substr(rcstcnatcnatcnatcnawther,5,1) s,
substr(rcstcnatcnatcnatcnawther,6,3) tc,
substr(rcstcnatcnatcnatcnawther,9,3) na,
substr(rcstcnatcnatcnatcnawther,12,3) tc2,
substr(rcstcnatcnatcnatcnawther,15,3) na2,
substr(rcstcnatcnatcnatcnawther,18,3) tc3,
substr(rcstcnatcnatcnatcnawther,21,3) na3,
substr(rcstcnatcnatcnatcnawther,24,3) tc4,
substr(rcstcnatcnatcnatcnawther,27,3) na4,
substr(rcstcnatcnatcnatcnawther,30,10) wther,
sno
from scott.sms1 a
where sno = (select max(sno)
from sms1
where sno != a.sno
); ---------------> added where clause with table alias.
end;Regards
Etbin -
Removing duplicate values from selectOneChoice bound to List Iterator
I'm trying to remove duplicate values from a selectOneChoice that i have. The component binds back to a List Iterator on the pageDefinition.
I have a table on a JSF page with 5 columns; the table is bound to a method iterator on the pageDef. Then above the table, there are 5 separate selectOneChoice components each one of which is bound to the result set of the table's iterator. So this means that each selectOneChoice only contains vales corresponding to the columns in the table which it represents.
The selectOneChoice components are part of a search facility and allow the user to select values from them and restrict the results that are returned. The concept is fine and i works. However if i have repeating values in the selectOneChoice (which is inevitable given its bound to the table column result set), then i need to remove them. I can remove null values or empty strings using expression language in the rendered attribute as shown:
<af:forEach var="item"
items="#{bindings.XXXX.items}">
<af:selectItem label="#{item.label}" value="#{item.label}"
rendered="#{item.label != ''}"/>
</af:forEach>
But i dont know how i can remove duplicate values easily. I know i can programatically do it in a backing bean etc.... but i want to know if there is perhaps some EL that might do it or another setting that ADF gives which can overcome this.
Any help would be appreciated.
Kind RegardsHi,
It'll be little difficult removing duplicates and keeping the context as it is with exixting standard functions. Removing duplicates irrespective of context changes, we can do with available functions. Please try with this UDF code which may help you...
source>sort>UDF-->Target
execution type of UDF is Allvalues of a context.
public void UDF(String[] var1, ResultList result, Container container) throws StreamTransformationException{
ArrayList aList = new ArrayList();
aList.add(var1(0));
result.addValue(var1(0));
for(int i=1; i<var1.length; i++){
if(aList.contains(var1(i)))
continue;
else{
aList.add(var1(i));
result.addValue(var1(i));
Regards,
Priyanka -
Exclude duplicate values on SQL where clause statement
Hi!
Are some posibilities to exclude duplicate values do not using sql aggregate functions in main select statement?
Priview SQL statement
SELECT * FROM
select id,hin_id,name,code,valid_date_from,valid_date_to
from diaries
QRSLT
WHERE (hin_id = (SELECT NVL(historic_id,id)FROM tutions where id=/*???*/ 59615))
AND NVL(valid_date_to,to_date('22.12.2999','dd.mm.yyyy')) <= (SELECT NVL(valid_date_to,to_date('22.12.2999','dd.mm.yyyy'))FROM tutions where id= /*???*/ 59615)
AND trunc(valid_date_from) >=(SELECT trunc(valid_date_from)FROM tutions where id= /*???*/ 59615)
The result
ID HIN_ID NAME CODE VALID_DATE FROM VALID_DATE_TO
50512
59564
RE TU
01
07.06.2013 16:32:15
07.06.2013 16:33:28
50513
59564
TT2
02
07.06.2013 16:33:23
07.06.2013 16:33:28
50515
59564
TT2
02
07.06.2013 16:33:28
07.06.2013 16:34:42
50516
59564
ROD
03
07.06.2013 16:34:37
07.06.2013 16:34:42
VALID_DATE_TO & AND VALID_DATE_FROM tutions
07.06.2013 16:34:42
15.07.2013 10:33:23
In this case i got duplicate of entry TT2 id 50513 In main select statement cant use agregate functions are even posible to exclude this value from result modifying only the QLRST WHERE clause (TRUNC need to be here)
THANKS FOR ANY TIP !
ID.Hi, Ok this is working in this case
SELECT * FROM
select id,hin_id,name,code,valid_date_from,valid_date_to
from diaries ahs
QRSLT
WHERE (hin_id = (SELECT NVL(historic_id,id)FROM aip_healthcare_tutions where id=/*???*/ 59615))
AND NVL(valid_date_to,to_date('22.12.2999','dd.mm.yyyy')) <= (SELECT NVL(valid_date_to,to_date('22.12.2999','dd.mm.yyyy'))FROM tutions where id= /*???*/ 59615)
AND trunc(valid_date_from) >=(SELECT trunc(valid_date_from)FROM tutions where id= /*???*/ 59615)
AND NOT EXISTS
(SELECT null FROM diaries ahs WHERE ahs.valid_date_from < QRSLT.valid_date_from
AND QRSLT.hin_id=ahs.hin_id
AND QRSLT.code=ahs.code);
Result
50512
59564
RE TU
01
07.06.2013 16:32:15
07.06.2013 16:33:28
50513
59564
TT2
02
07.06.2013 16:33:23
07.06.2013 16:33:28
50516
59564
ROD
03
07.06.2013 16:34:37
07.06.2013 16:34:42
But if the Data in tutions row are theese(valid_date_to-null) then NO ROWS are returning and its logical because in full result list Valid_date_from column are logical incorect
valid_date_from valid_date_to
15.07.2013 10:33:23
NULL
ID HIN_ID NAME CODE VALID_DATE FROM VALID_DATE_TO
50510
59564
RE TU
01
07.06.2013 16:33:28
50511
59564
TT2
02
07.06.2013 16:34:41
50514
59564
ROD
03
07.06.2013 16:34:41
50520
59564
Params
04
03.07.2013 21:01:30
50512
59564
RE TU
01
07.06.2013 16:32:15
07.06.2013 16:33:28
50513
59564
TT2
02
07.06.2013 16:33:23
07.06.2013 16:33:28
50515
59564
TT2
02
07.06.2013 16:33:28
07.06.2013 16:34:42
50516
59564
ROD
03
07.06.2013 16:34:37
07.06.2013 16:34:42
Are that posible modifying where statement if the valid_date_to in tutions are null then theese records where in diary valid_date_to is null is correct to, but need to stay previos logic
D HIN_ID NAME CODE VALID_DATE FROM VALID_DATE_TO
50510
59564
RE TU
01
07.06.2013 16:33:28
null
50511
59564
TT2
02
07.06.2013 16:34:41
null
50514
59564
ROD
03
07.06.2013 16:34:41
null
50520
59564
Params
04
03.07.2013 21:01:30
null
Thanks !
ID. -
Dear All
I have received common error when creating relation:
The relationship cannot be created because each column contains duplicate values. Select at least one column that contains only unique values.
The issue is strange because I am sure that there are no duplicate values in my table! I checked it.
What I've done was to create a single column "Append column" by append few columns with articles from different databases using Power Query. After that I removed duplicates.
The final column with unique values was added to powerpivot model as a new table. There are no duplicates and spaces.
Then I tried to create the relation between the column with append values and other databases which I had used to create this column.
So it is look like this:
Details of error:
Error Message:
============================
The relationship cannot be created because each column contains duplicate values. Select at least one column that contains only unique values.
============================
Call Stack:
============================
at Microsoft.AnalysisServices.Common.RelationshipController.CreateRelationship(DataModelingColumn sourceColumn, DataModelingColumn relatedColumn)
at Microsoft.AnalysisServices.Common.RelationshipController.CreateRelationship(String fkTableName, String fkColumnName, String pkTableName, String pkColumnName)
at Microsoft.AnalysisServices.Common.SandboxEditor.erDiagram_CreateRelationshipCallBack(Object sender, ERDiagramCreateRelationshipEventArgs e)
at Microsoft.AnalysisServices.Common.ERDiagram.ERDiagramActionCreateRelationship.Do(IDiagramActionInstance actionInstance)
============================
What could be a reason of this issue?Thanks recio but your solutions not works
I have found the issue but not a solution.
The problem is that there is a space at the end of some articles names.
In my Database 1 I have an "a" article but
in my Database 2 I have an "a_"
where "_" is invisible space character
So PowerQuery and excel "Remove duplicate" function did not find duplicates but Powerpivot see ones
My data model looks like as on example below
So now my question is how to automaticly get rid of space character to be able to create relation?
As I see power Query does not have such an option. Maybe a look up formula in PowerPivot? But how it should look like
This is how my "Append column" Should look like: -
Retrieving duplicate values from a table
I have a table that has 80,000 rows. One column contains text identifiers as varchar2. There are almost all unique. A select count(distinct id) statement returns 79,980 rows. Is there a way to return only the remaining 20?
To know the unique values you can do this. but it would not return the rows, only the 20 or less duplicate values.
SELECT textColumn, count(*) as cnt_occurences
FROM yourTable
GROUP BY txtColumn
HAVING count(*) > 1; -
Colour duplicate values in html output
Hello,
I am looking to colour duplicate values in an html output file.
I have written a folder comparison ps script which shows output as below:
Name Length Version
Name length and version are the column names
Now there are many duplicate entries under name column which I need to highlight using any one colour. I have sorted the output under name using alphabetical order.
I just need to highlight all duplicate values using a particular colour.
Thanks in advance.Posting my script here:
# Get Start Time
$startDTM = (Get-Date)
$a = "<style>"
$a = $a + "BODY{background-color:peachpuff;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
$a = $a + "</style>"
$folderReference = Read-Host "Enter Reference Folder Name"
$folderDifference = Read-Host "Enter Difference Folder Name"
$FolderReferenceContents = Get-ChildItem $folderReference -Recurse |
where-object {-not $_.PSIsContainer}
$FolderDifferenceContents = Get-ChildItem $folderDifference -Recurse |
where-object {-not $_.PSIsContainer}
#get only files that are on reference folder not base folder
$one = Compare-Object -ReferenceObject $FolderReferenceContents `
-DifferenceObject $FolderDifferenceContents -Property ('Name', 'Length','Get-FileVersionInfo') -PassThru |
where-object { $_.SideIndicator -eq '<='} | select Name, Length, LastWriteTime, VersionInfo
#get only files that are on base folder not on reference
$two = Compare-Object -ReferenceObject $FolderReferenceContents `
-DifferenceObject $FolderDifferenceContents -Property ('Name', 'Length','Get-FileVersionInfo') -PassThru |
where-object { $_.SideIndicator -eq '=>'} | select Name, Length, LastWriteTime, VersionInfo
$three = $one + $two | sort-object -property Name | ConvertTo-HTML -Fragment
# Get End Time
$endDTM = (Get-Date)
# Echo Time elapsed
$four = "Elapsed Time: $(($endDTM-$startDTM).totalseconds) seconds"
ConvertTo-HTML -Head $a -Body "$one $two $three $four" -Title "Output" | Out-File C:\output.html -
How to delete duplicate values in a column?
consider a table contains 2 columns(NAME & DEPARTMENT)
NAME DEPARTMENT
santhosh finance
santhosh marketing
rahul sales
stephen IT
stephen sales
In the above table how to delete only the duplicate values(santhosh,stephen) in the column?If you don't care??
delete emp
where 1 < (select row_number() over(partition by deptno order by 1) from emp)
Error at line 1
ORA-01427: single-row subquery returns more than one rowI'd use something like
delete emp e1
where exists
(select null
from (select deptno, rowid rid, row_number () over (partition by deptno order by 1) rn from emp) e2
where e1.rowid = e2.rid
and 1 < rn) -
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 -
Loop not working for check of duplicate values in a repeating table
I have a form that is used for marking down problem items, describing the problems and assigning a value to the specified item. In some cases the problems belong to the same class. When they do, the value associated with the problem should only be marked once. If another problem in the same class is documented the value should not be recorded the second time. I have a variable that is called based on a switch statement in the exit event of the field that records the problem item number. The script in the variable is then supposed to check for duplicate values in the table. If no other problem item in that class is selected, then the problem value should be assigned a number. If another item from the same class has already been entered, then the problem value should just be left blank. I will paste the script for the variable below as well as the switch statement. When I used to call the variable based upon the change event for the problem item, the script work. At that time, the switch statement was related to a drop-down menu. We decided to get rid of the drop-down and just have the used type the item number. But to do so, I had to move the switch statement to the exit event for the field. when I did this, the script in the variable no longer worked properly. Here is the switch statment followed by the script in the variable:
this.rawValue = this.rawValue.toLowerCase();
var bEnableTextField = true;
var i = "Inspection Criteria: ";
var r = "Required Corrections: ";
switch (this.rawValue)
case "1a": // 1a- First debit option
CorrectionsText.CorrectionLang = r+"Correction description for 1st debit";
ViolCorrSection.ViolationsText.DebitVal = "C";
ViolCorrSection.Reference.RefLanguage = i+"1st debit reference";
break;
case "1b": // 1b- Second debit option
CorrectionsText.CorrectionLang = r+"Correction description for 2nd debit";
ViolCorrSection.Reference.RefLanguage = i+"2nd debit reference";
myScript.group1();
break; //the script continues for various item numbers...
________________ variable script ________________________
function group1()
//Used in checking duplication of violations
var oFields = xfa.resolveNodes("form1.MAINBODYSUB.ViolationsTableSubform.ViolationsTable.ViolCorrSectio n[*].ViolationsText.ItemNo"); // looks to resolve the repeating rows
var nNodesLength = oFields.length; //assigns the number of rows to a variable
var currentRow = xfa.resolveNode("form1.MAINBODYSUB.ViolationsTableSubform.ViolationsTable.ViolCorrSection ").index;
var currentDebit = xfa.resolveNode("form1.MAINBODYSUB.ViolationsTableSubform.ViolationsTable.ViolCorrSection [" + currentRow + "].ViolationsText.DebitVal");
for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) // this loops through Item Numbers looking for duplicate violations
//console.println("nNodeCount: " + nNodeCount);
var nFld = xfa.resolveNode("form1.MAINBODYSUB.ViolationsTableSubform.ViolationsTable.ViolCorrSection [" + nNodeCount + "]");
//console.println("nFld.ViolationsText.ItemNo: " + nFld.ViolationsText.ItemNo.rawValue);
if (nFld.ViolationsText.ItemNo.rawValue == "1a" || nFld.ViolationsText.ItemNo.rawValue == "1b" || nFld.ViolationsText.ItemNo.rawValue == "1c" || nFld.ViolationsText.ItemNo.rawValue == "1d") // looks for other 1s
currentDebit.rawValue = "";
nNodeCount = nNodesLength; // stop loop
else
currentDebit.rawValue = "5";
So, if you enter 1b the first time, you should get a value of 5 appearing in the debit value field. If you enter 1c next, because it belongs to the same group of class of problem items, there should be no value assigned. What happens now is that the values for 1b and 1c don't appear at all because the form thinks that the first 1b entry already existed.
Any ideas? I have a stripped down version of the form that I can email to someone for reference if that would help. Thanks
P.S. I am working with LiveCycle Designer ES 8.2.1....Hi,
I can have a look at your form, but can you host it somewhere like Acrobat.com or google docs and add a link to it here.
Regards
Bruce
Maybe you are looking for
-
How do i duplicate a file that is on acrobat. com?
The duplicate file function is there if the document is in my documents. But it is not there if the file is saved on acrobat.com
-
Macbook does not wake from sleep properly.
My macbook 2.0ghz core duo, 10.5.6 does not wake form sleep like it should. it behaves similar to when it runs out of battery with a pale screen and a loading bar, like it is restoring the system from the sleep image, although the battery is full. Ha
-
I'm having trouble sending a photo with my emails. It keeps saying Missing Plug-In when the email is sent from Mac Mail. I'm running Mountain Lion currently. I've also tried the Java Setting reset but it didnt help. Thanks
-
Hello everyone. I'm hoping someone can help me with a problem I'm having running one of the Survey Builder API's. I need to edit certain survey fields using the following API: OPC_SURVEY_BUILD.EDIT_SURVEY. The problems is that when I try to run this
-
I'm running FCP6 on a macbook pro. I've moved a project from my MacPro system (running FCP6) so that I can work on it while I'm on the road. I moved the "project title" media folder from the capture scratch into a new capture scratch folder on the dr