How to test if there are duplicate values in a column using PL/SQL
Hello,
I want to be able to test if there are duplicate values (VARCHAR2) in a particular column of the database using PL/SQL.
Thanks
Douglas
If I have understood your requirement, then you are asking for a query like following.
Select column_name from Tbl_name
group by column_name
having count(*) > 1;
Similar Messages
-
Split one column value into two columns using t-sql
Hi All,
I have one varchar column in a table.
Col1
ABC-12C4
BC-A345
CD
XYZ
How to split this into two columns like this using t-sql
Col1 Col2
ABC 12C4
BC A345
CD
XYZ
Thanks,
RH
sqlassuming a static delimiter, and the split will end up with a max of 2 columns, something like this would work. basically you just need to determine where the delimiter is, and then use the left and right functions to find the 2 pieces.
declare @t table(value varchar(10))
insert into @t(value)
values
('ABC-12C4'), ('BC-A345'), ('CD'), ('XYZ')
select
case
when charindex('-', value) != 0 then left(value, charindex('-', value) - 1)
else value
end as col1,
case
when charindex('-', value) != 0 then right(value, len(value) - charindex('-', value))
else ''
end as col2
from @t -
How find out the duplicate value from each columns.
I have below four columns,
How can i find out the duplicate value from each columns.
with All_files as (
select '1000' as INVOICE,'2000' AS DELIVERYNOTE,'3000' CANDELINVOICE,'4000' CANDELIVERYNOTE from dual union all
select '5000','6000','7000','8000' from dual union all
select '9000','1000','1100','1200' from dual union all
select '1200','3400','6700','8790' from dual union all
select '1000','2000','3000','9000' from dual union all
select '1230','2340','3450','4560' from dual
SELECT * FROM All_files
Output should be as per below.
1000 2000 3000 4000
9000 1000 1100 1200
1200 3400 6700 8790
1000 2000 3000 9000
Required to check uniqueness in cross columns.
Thanks.Try this (sorry about the formatting)...
WITH all_files AS (SELECT '1000' AS INVOICE,
'2000' AS DELIVERYNOTE,
'3000' CANDELINVOICE,
'4000' CANDELIVERYNOTE
FROM DUAL
UNION ALL
SELECT '5000',
'6000',
'7000',
'8000'
FROM DUAL
UNION ALL
SELECT '9000',
'1000',
'1100',
'1200'
FROM DUAL
UNION ALL
SELECT '1200',
'3400',
'6700',
'8790'
FROM DUAL
UNION ALL
SELECT '1000',
'2000',
'3000',
'9000'
FROM DUAL
UNION ALL
SELECT '1230',
'2340',
'3450',
'4560'
FROM DUAL),
t_base
AS (SELECT invoice
|| ','
|| deliverynote
|| ','
|| candelinvoice
|| ','
|| candeliverynote
str
FROM all_files),
t_str
AS (SELECT str || ',' AS str,
(LENGTH (str) - LENGTH (REPLACE (str, ','))) + 1
AS no_of_elements
FROM t_base),
t_n_rows
AS ( SELECT LEVEL AS i
FROM DUAL
CONNECT BY LEVEL <=
( SELECT SUM (no_of_elements) FROM t_str)),
t_build AS (SELECT t_str.str,
nt.i AS element_no,
INSTR (t_str.str,
DECODE (nt.i, 1, 0, 1),
DECODE (nt.i, 1, 1, nt.i - 1))
+ 1
AS start_pos,
INSTR (t_str.str,
1,
DECODE (nt.i, 1, 1, nt.i))
AS next_pos
FROM t_str
JOIN
t_n_rows nt
ON nt.i <= t_str.no_of_elements),
t_build2
AS (SELECT RTRIM (str, ',') AS original_string,
SUBSTR (str, start_pos, (next_pos - start_pos))
AS single_element,
element_no
FROM t_build),
t_build3
AS (SELECT single_element,
COUNT( * )
OVER (PARTITION BY single_element
ORDER BY single_element)
ele_count
FROM t_build2)
SELECT DISTINCT INVOICE,
DELIVERYNOTE,
CANDELINVOICE,
CANDELIVERYNOTE
FROM all_files, t_build3
WHERE ele_count > 1
AND ( INVOICE = single_element
OR DELIVERYNOTE = single_element
OR CANDELINVOICE = single_element
OR CANDELIVERYNOTE = single_element)I think this will be faster than the previous solution?
Cheers
Ben
Edited by: Munky on Feb 17, 2011 2:11 PM - "I think this will be faster than the previous solution?", nope - it's not :( -
How do I show my iCloud purchases in iTunes, but prevent it from showing duplicates of the songs I already have on my computer? There are duplicates of essentially everything!
I would like to show my available songs that I could download if I want, however the ones I've already downloaded to my computer are showing up still, which results in duplicates of everything (one on my computer, one in the cloud)No.
Are the photos in an iTunes backup? If so then:
- You can restore another iPod touch, iPhne or iPad from that backup
- Extract the photos from that backup by
How to perform iPad recovery for photos, videos
Wondershare Dr.Fone for iOS: iPhone Data Recovery - Wondershare Official
http://www.amacsoft.com/ipod-data-recovery.html
Otherwise maybe a data recovery company can help. Not cheap. -
How many notes(annotations) there are? Is detection possible?
I can create move notes from code but first I must know how many text Notes there are in a document.
Is it possible using executeActionGet(ref) ?I must know how many text Notes there are in a document.
Is it possible using executeActionGet(ref) ?
Not directly, however it seems that a work-around is possible.
The following code is adapted from a snippet written by the brilliant Paul Riggott; it works for me in CS4:
ps-scripts.com • View topic - Annotation functions.
function hideAnnotation (index) // Dummy action, only used to test the existence of an annotation by index...
var exists = true;
var desc = new ActionDescriptor ();
var ref = new ActionReference ();
ref.putIndex (stringIDToTypeID ('annotation'), index);
desc.putReference (stringIDToTypeID ('target'), ref);
try
executeAction (stringIDToTypeID ('hide'), desc, DialogModes.NO);
catch (e)
exists = false;
return (exists);
function getAnnotationCount ()
var index = 0;
while (hideAnnotation (index))
index++;
return index;
alert (getAnnotationCount ());
HTH,
--Mikaeru -
Mac won't let me move files into a folder bc it THINKS there are duplicate files - but they're not
Mac won't let me move files into a folder bc it THINKS there are duplicate files - but they're not. There are hundreds of what it thinks are duplicates. How can I get it to let me put them all into a folder and create unique names? If I do one file at a time, it gives me the option to keep both files. But not when I am moving hundreds at a time.
A reply to an old problem, but I couldn't find this solution anywhere. I had the same problem when I moved my iTunes library to an external drive. As Apple recommends, I used File > Library > Organize Library > Consolidate Files to copy my music files from my overstuffed hard drive to the external drive. Copying went fine for a while, adding about two-thirds of my files to the new drive without incident. Then I got the big stop sign with the error message: "Copying files failed. The disk could not be read from or written to."
This turned out to have nothing to do with either the hard drive or the external disk. I had a bad file in my music library that was shutting down the consolidation process. Unfortunately the error message says nothing about which file may be the culprit. All I could think to do was to go back to my original library in iTunes and sort by Artist, select all cuts with artists beginning with A, right click and select "Consolidate Files". Then do the same with B artists, etc. Proceeding this way, files resumed copying but when I got to the "S" selections, the consolidate process failed again. Then I selected smaller and smaller batches until the problem file was identified. Removed it from my library and then Consolidate worked fine through the rest of the library. Problem solved.
I spent several days working through this; hope I can save someone else the time. -
Hi. I'm in a situation here and would really welcome some guidance. I dragged my ext. HD iTunes backed up folder into my new mac. Now there are duplicates of every song. Both versions seem to actually BE there when I check the info. So, I moved what I thought were duplicates into the trash from iTunes, and resigned myself to the fact that I would have to do this manually for each album. I did this with about 10 albums. I emptied the trash and lost them even though they still LOOKED like they were in iTunes. I repeated the process tonight on a bunch of other albums not realizing yet that I had screwed up terribly the first time. This time I saw what had happened and pulled the files out of the trash, onto my desktop and dragged them back into iTunes, then deleted the duplicate files that had exclamation points next to them. Now I have no idea if iTunes is playing duplicate files from the trash or not, and am nervous about emptying the trash. Anyone dealt with this before? Thank you
Hi. I'm in a situation here and would really welcome some guidance. I dragged my ext. HD iTunes backed up folder into my new mac. Now there are duplicates of every song. Both versions seem to actually BE there when I check the info. So, I moved what I thought were duplicates into the trash from iTunes, and resigned myself to the fact that I would have to do this manually for each album. I did this with about 10 albums. I emptied the trash and lost them even though they still LOOKED like they were in iTunes. I repeated the process tonight on a bunch of other albums not realizing yet that I had screwed up terribly the first time. This time I saw what had happened and pulled the files out of the trash, onto my desktop and dragged them back into iTunes, then deleted the duplicate files that had exclamation points next to them. Now I have no idea if iTunes is playing duplicate files from the trash or not, and am nervous about emptying the trash. Anyone dealt with this before? Thank you
-
Can not take a screenshot with Maverick and track pad. can not use apple chat to talk with a tech. there are other issues also like I used to be able to go back a page with the delete button. No Maverick PDF to instruct on how to use Maverick
THE use of the apple support is a mess also.
I want to be able to use my MAC fully and easily like I used to with Snow Leopard.
What is wrong with this maverick OS?The only people who can possibly assist you with this is Apple Customer Relations, call your local Apple contact number and ask for Customer Relations then explain your situation clearly and politely (be firm but don't rant).
You might want to investiage what the local laws are regarding defective goods and 'fit for use' definitions on warranties etc. Consumer Protection can be a useful tool to use or bargain with if needed ... -
Function to calculate how many working date there are.
Good morning,
there is a Function/Object to calculate how many working days there are between two dates?
thanks
MIf you have problems finding in the forum the answer to this question, please re-post it and mention how you searched and how the results didn't help.
Thread locked.
Rob -
i have made one field as drop down in web ui. there are 3 values in drop down suppose a, b , c.
now i want to make c value as default value in drop down what to do?Hello Bala,
you can find number of discussions regarding this on SCN.
Search and do code in DO_INIT_CONTEXT method of view to set the value in entity.
lr_entity ?= me->typed_context->context_node_name->collection_wrapper->get_current( ).
lr_entity->set_property( iv_attr_name = 'Attribute_name' iv_value = 'value' ).
Regards Harish Kumar -
How to fetch the Business area field value from MIRo into report
Hi,
I want to create a report for MIRO with payment details.
How to fetch the business area field value in to report.
What is the table name. I verified it is storing in structure. Which is the right table for fetching that value with reference to MIRO.
After that, how to find the accounting document for payment and check details.
What are the table names and field names. What we can get from PAYR table.
With regards
LakkiDear,
For Bussiness area
RKPF-GSBER -
Keeps hanging up saying there are duplicate files, then stalling out
Compressor will compress my video all the way to half way, then red exclamation marks will appear next to the two files saying that there are duplicate files with the same name... to preserve the original files change the name of the file I'm compressing. So I change the name, and then the progress line stalls out forever like it gets stuck after it tells me to change the name.
Actually, this sounds like normal behavior.
When you click the submit button, Compressor passes the encoding job to QMaster. QMaster then starts writing the necessary files in the destination that you set with the filename that you set.
Compressor sees the new files being written into your destination, and puts up the alert. This is standard behavior. There is no need to change the output filename in Compressor once the job has been submitted.
Compressor doesn't need to be kept open once you submit the job. To monitor the encoding, open Batch Monitor. -
how and where do I the the latest IOS for IPAD!!!
Fredronalderman wrote:
there are apps I would like to use that require 6.0 or later. how do i get the most recent ios 7.0.3?
Finding iOS Apps Compatible with Older Devices
App Store: Downloading Older Versions of Apps -
Finding duplicate values in a column with different values in a different c
I'm finding duplicate values in a column of my table:
select ba.CLAIM_NUMBER from bsi_auto_vw ba
group by ba.CLAIM_NUMBER
having count(*) > 1;
How can I modify this query to find duplicate values in that column where I DON'T have duplicate values in a different specific column in that table (the column CLMT_NO in my case can't have duplicates.)?Well, you can use analytics assuming you don't mind full scanning the table.....
select
count(owner) over (partition by object_type),
count(object_type) over (partition by owner)
from all_objects;You just need to intelligently (i didn't here) find your "window" (partition clause) to sort the data over, then make use of that (the analytics would be in a nested SQL and you'd then evaluate it in outside).
Should be applicable if i understand what you're after.
If you post some sample data we can mock up a SQL statement for you (if what i tried to convey wasn't understandable). -
From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?
Hi,
Use NVL or COALESCE:
NVL (col_a, col_b)
Returns col_a if col_a is not NULL; otherwise, it returns col_b.
Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Maybe you are looking for
-
I have a mac pro running the Yosemite OS. I have a HP Photosmart C4589 all in one printer that had been working fine until I replace my router. Now I can only use the printer as a usb. I know I need to change the wireless settings in the printer bu
-
Problem in refreshing data model
Hi, I am struggling in solving this issue for quite some time. I am developing a fusion web application using Jdeveloper 11.1.2. I have 3 view objects groups,employees and dependents. All the three view objects have binding variables and view criteri
-
Pl/sql function overload package program and how to execute
--creation overload package create or replace package pkg_overload is procedure get_emp(p_empid in number,p_empsal out number); procedure get_emp(p_ename in varchar2, p_empsal out number); end; -- define its body create or replace package body pkg_ov
-
Your request could not be completed error on the iPhone
Hi, Since yesterday, without having changed anything on my iPhone 4S, when trying to go to the FEATURED apps on my iphone, I get the YOUR REQUEST COULD NOT BE COMPLETED error. All other tabs (top 25, search, updates, categories etc...) work. Only the
-
Color value shift from Illustrator to Photoshop
Hi there: Hopefully someone has an answer for me (my apologies if this has been addressed before)? When I open up a EPS file in Illustrator, the blacks read !00% for RGB. When exported as a JPG, Photoshop reads it as 0-0-0. So far so good. But when c