retriving of unique records on two columns
Hello world
Using sql query, that he must retrieve unique records on two columns.
Example of table source: raster columns [uwi, well_no]
Examples of data below
UWI well_no
----- --------
1 988311
1 988311
1 1032662
1 1032662
2 103
2 103
2 103
3
3 104
3 104
3 104
4 106
4 107
4
4 108
For a given
UWI: 1 there are 4 well_no which is having two distinct values where these documents I need to go get
UWI: 2 there are 3 well_no, all 3 well_no contains the same value as (103) Consequently, these documents should not seek
UWI: 3 there are 4 well_no (1 null and 3 values are the same (104)] where these records should not seek.)
UWI: 4 there are 4 well_no which is to have three separate with a single value zero so these 4 files, I need to get.
output:
UWI well_no
----- --------
1 988311
1 988311
1 1032662
1 1032662
4 106
4 107
4
4 108
Thank you
Jery
Hi, Michel,.
Whenever you have a question, please post CREATE TABLE and INSERT statements for your sample data, so people who want to help you can recreate the problem and test their ideas.
Format your message so that it is easy to read and understand.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002
Maybe you want something like this, which shows information about the jobs that have deptnos 2 or more not NULL:
WITH got_cnt AS
(
SOME jobs, deptno
, ACCOUNT (SEPARATE deptno) RESUMED (work PARTITION) AS cnt
FROM scott.emp
)
SOME jobs, deptno
OF got_cnt
WHERE cnt > 1
;
Tags: Database
Similar Questions
-
Hi all
I want a unique index on two columns, but when I try this it will show me
I want to do not overlap with the combination of these two1 CREATE UNIQUE INDEX sale_order_no 2* ON sale_order (sale_order_no, season_year) SQL> / ON sale_order (sale_order_no, season_year) * ERROR at line 2: ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found
Plaese Guide
Thanks and greetings
VikasYou would this behavior if SALE_ORDER_NO has NULL values. If it contains NULL values, a unique single-column index will succeed but an index unique multi-column will fail when it finds duplicates in SEASON_YEAR.
See:
SQL> create table dummy_objects (object_id number, object_owner varchar2(30), object_name varchar2(30)); Table created. SQL> insert into dummy_objects values (0,'HEMANT','TABLE_A'); 1 row created. SQL> insert into dummy_objects values (1,'HEMANT','TABLE_B'); 1 row created. SQL> insert into dummy_objects values (NULL,'HEMANT','NULL_1'); 1 row created. SQL> insert into dummy_objects values (NULL,'HEMANT','NULL_2'); 1 row created. SQL> create unique index dummy_objects_u1 on dummy_objects(object_id); Index created. SQL> drop index dummy_objects_u1; Index dropped. SQL> create unique index dummy_objects_u2 on dummy_objects(object_id, object_owner); create unique index dummy_objects_u2 on dummy_objects(object_id, object_owner) * ERROR at line 1: ORA-01452: cannot CREATE UNIQUE INDEX; duplicate keys found SQL>
Hemant K Collette
http://hemantoracledba.blogspot.com -
Unique index on two columns based on the conditon
I have a table where I have two columns name and feed.
I want to create a unique index for the lines abc - L3 and cant abc - both together be inserted, rest the other flow values is not a problem, so the first two rows can not be there in the table.create table test1 (name varchar(20), feed varchar(4)); insert into test1 values('abc','L3'); insert into test1 values( 'abc','Both'); insert into test1 values('abc','L2');
Please suggest
Thajscreate unique index test1_ind1 on test1 (name, case when feed = 'Both' then 'L3' else feed end );
Who did what you asked...
However, I highly doubt it does what you WANT.
Please provide information on the requirements, and we the flesh that out a little better.
-
How to retrieve unique records with multiple columns
I have a sps_prod table as described below-
POGNAME VARCHAR2 (1500)
INDEX #VERSION VARCHAR2 (200)
POG_MODEL_STATUS VARCHAR2 (100)
POG_LAYOUT_TYPE VARCHAR2 (500)
POG_MARKET_SPECIFIC VARCHAR2 (500)
POG_CONTACT_NUMBER VARCHAR2 (100)
AREA_SUPPORTED VARCHAR2 (500)
POG_COMMENTS VARCHAR2 (1500)
POG_FOOTER_COMMENTS VARCHAR2 (1500)
POG_ELECTRICAL_LIST_1 VARCHAR2 (1500)
POG_ELECTRICAL_LIST_2 VARCHAR2 (1500)
POG_CARPENTRY_1 VARCHAR2 (1500)
POG_CARPENTRY_2 VARCHAR2 (1500)
INSTALLATION_INSTRUCTION_1 VARCHAR2 (1500)
INSTALLATION_INSTRUCTION_2 VARCHAR2 (1500)
FIXTURE_REORDER_NUMBER VARCHAR2 (200)
FIXTURE_ID VARCHAR2 (200)
FIXTURE_NAME VARCHAR2 (500)
FIXTURE_IMAGE VARCHAR2 (500)
PART_REORDER_NUMBER_9 VARCHAR2 (500)
PART_FIXTURE_ID_9 VARCHAR2 (500)
PART_FIXTURE_NAME_9 VARCHAR2 (500)
PART_FIXTURE_IMAGE_9 VARCHAR2 (500)
UPC VARCHAR2 (50)
ITEM_NUMBER VARCHAR2 (50)
DESCRIPTION VARCHAR2 (700)
MERCH_TYPE VARCHAR2 (20)
HEIGHT VARCHAR2 (100)
WIDTH VARCHAR2 (100)
DEPTH VARCHAR2 (100)
DATE OF CREATE_TS
There are 4 million records in it and many with the same combination of POGName, #Version, POG_Model_Status, POG_Layout_Type, POG_Market_Specific, POG_Contact_Number and Fixture_Name Index. How do the records to retrieve all the columns above, but with a unique combination of fixture_name and reorder_number. It has no keys defined on the table.
I guess that it is a simple problem but the fact I'm trying to retrieve all the columns I'm stumbling.
Thanks in advance.Hello
Sanders_2503 wrote:
... There are 4 million records in it and many with the same combination of POGName, #Version, POG_Model_Status, POG_Layout_Type, POG_Market_Specific, POG_Contact_Number and Fixture_Name Index. How do the records to retrieve all the columns above, but with a unique combination of fixture_name and reorder_number.I don't see a column named reorder_number. Do you mean fixture_reorder_number or part_reorder_number_9?
So, you want only one row for each distinct combination of fixture_name and some other column (I'll assume it's fixture_reorder_number). Does it matter which line? They will not necessarily have the same values for the other columns.
The following query returns the one with the first pogname (in sort order):WITH got_r_num AS ( SELECT pogname, index#version, pog_model_status, pog_layout_type , pog_market_specific, pog_contact_number, fixture_name , ROW_NUMBER () OVER ( PARTITION BY fixture_name , fixture_reorder_number ORDER BY pogname ) AS r_num FROM sps_prod ) SELECT pogname, index#version, pog_model_status, pog_layout_type , pog_market_specific, pog_contact_number, fixture_name FROM got_r_num WHERE r_num = 1 ;
If there be a tie (i.e. two or more lines with the same fixture_name, fixture_number and pogname first) and then the will be chosen arbitrarily.
Instead of "ORDER BY pogname", you can ORDER all the other columns OR expressions, but you must have an ORDER byclause of analytics. You can do "ORDER BY NULL" If you really want pcik an arbitrary line.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements), and also publish the results you want from these data (or some examples of acceptable results).
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. -
Index on two columns becomes the index of function?
Hello, I create a unique index with two columns, a number (9) and a date.
It becomes an index of feature based with the number column and a column sys hidden (date).
When I do queries that use this index the autotrace tells me it does things like this:
sys_nc00001$ > SYS_OP_DESCEND (datevalue)
sys_nc00001$ IS NOT NULL
How is he did not have a normal index?Use of ESCR does this.
Of http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_5010.htm
Oracle database processes Index descending as if they were focused on the index function.
-
extraction of unique records of registration of two different tables
Hello
In the following two tables different www.testing.com code exists in both tables. I want to compare two different columns from two different tables for unique records.
Thank you and best regardsSQL> select unique(videoLinks) from saVideos where sa_id=21; VIDEOLINKS ----------------------------------------------------------------------- www.testing.com SQL> ed Wrote file afiedt.buf 1* select unique(picLinks) from saImages where sa_id=21 SQL> / PICLINKS ----------------------------------------------------------------------- test test14 www.hello.com www.testing.com
Try
Select unique (videoLinks) in the saVideos where sa_id = 21
Union
Select unique (picLinks) in the saImages where sa_id = 21 -
Hello
Actually I got to know this update of a record must be made when the primary key is based on two columns.
Previously, I used SPEL for a column. It was working fine.
But I came to know that regardless of the folder I try to update, it was the update page is coming up with the first combination of the record.
As if RC 131
RC 124
RC 125 are the records.
If I click on update of RC 124 also, the update page is coming up with RC 131 values as it is the first.
So I understand that the SPEL should be based on two parameters, because it is a composite key.
How to do?
Please let me know if you don't understand the problem.
Thank you.
Wow!
I got it.
Thank you brothers, always a hope that you could help me
-
Two columns must be UNIQUE if the second is not NULL.
Two columns must be UNIQUE if the second is not NULL. If the second is NULL, the first has no need to be UNIQUE.
CREATE TABLE Moo ( Prima INT PRIMARY KEY, Secunda INT NOT NULL, Tertia VARCHAR2(1) ); CREATE UNIQUE INDEX Cow ON Moo(Secunda, NVL(Tertia, TO_CHAR(Prima))); INSERT INTO Moo(Prima, Secunda, Tertia) SELECT 1, 1, NULL FROM Dual UNION ALL SELECT 2, 1, NULL FROM Dual; DROP TABLE Moo;
Is there another way to do it?
Added 'SINGLE '.
I had a little trouble at matches your description to your example, but if you want to apply the uniqueness on (secunda, tertia) only for lines where tertia is not null, then the following should work:
create an index unique xxx on moo)
cases when is not null, then end of secunda, tertia
Tertia
);
Concerning
Jonathan Lewis
P.S. When do a quick test of the best way to define this index, I found what seems to be a bug in 11.2.0.4 (and maybe other versions) with the expression:
Tertia case if no then cast (null as an int) to another end secunda
Update: now blog at: Easy & #8211; Oops. | Notebook of the Oracle
-
Conversion of an array of unique column in a table of two columns
Hello world
What I'm trying to do is to convert a single column table in a table with two columns. Here is an example:
Table (column):
ID1
ID2
ID3
ID4
ID5
Table B (two columns) must be:
ID1 ID2
ID3 ID4
ID5
I've been browsing through a cursor and do an insert every 2 rows, but do not like performance.
Is there a more easy/fast way to do this?
Thanks in advance
Oscarwith t as ( select 'ID1' col1 from dual union all select 'ID2' from dual union all select 'ID3' from dual union all select 'ID4' from dual union all select 'ID5' from dual ) -- end of sample table select col1, col2 from ( select col1, lead(col1) over(order by col1) col2, row_number() over(order by col1) rn from t ) where mod(rn,2) = 1 / COL COL --- --- ID1 ID2 ID3 ID4 ID5 SQL>
SY.
-
SQL query * I want to insert a file column in the other table based on two columns
I want to insert a column records to another table based on two columns
the query below does not work
insert into def_ver_lnki_p (job_name)
Select def_job.job_name
from def_job where def_job.job_id = def_ver_lnki_p.job_id and def_job.table_id = def_ver_lnki_p.table_id;
Just to correct sql
Update
def_ver_lnki_p define job_name =)
Select def_job.job_name
of def_job
where def_job.job_id = def_ver_lnki_p.job_id
(and def_job.table_id = def_ver_lnki_p.table_id);
-
Insertion of a middle Page of separate text on a two column layout box
Hello!
I'm working on a book with a layout in two columns. At various times, I need to insert what are effectively the chapter breaks. Currently I have a giant text block flowing for all 65 pages. This provision is (I think?) made necessary by the scripts that I am running for our line numbers and our notes.
My original idea was to put the chapter title in a separate text block and wrap the text around it, so that I can keep the unique setting of the main text. Unfortunately, in the two-column layout, this means that the text in the first column went * under * the title of the chapter to complete the first column, no matter where I moved it.
I think I may need to end the block of text of the first chapter and start a second for the new chapter get the result I want. However, I have a few worries about that: first of all, if I ended up simply text block, I should remove the other 55 pages (after the break) I already partially formatted and screw them from scratch in the text box of the new chapter? Secondly, I also fear that making a separate text block could ruin my scripts endnote and line numbers.
(NB: if I need to put an end to this block of text and starting a new one, I can't find a way to do it on a page at the beginning of a block of text in several pages, so I need help with this, too.)
Y at - it a simple way to insert this text box so that text of the first chapter ends perfectly in two columns above it, and the next chapter starts cleanly into two columns underneath?
Please see attached screen captures, showing the current state of things. The text box has been inserted with a simple wrap around it.
THANK YOU IN ADVANCE!
Hello
Have you checked characteristic Columns Span integrated InDesign? http://InDesignSecrets.com/timesaver-span-and-split-columns-in-CS5.php
Now that you have your text formatted in a single framework with two columns, you can select the chapter header text and tell him to cover all the columns in the text block.
This warp the need to set up a separate text frame.
The only downside I can think is that you use the the duration columns can slow down InDesign a bit.
Ariel
-
two column values in a single column
Hi guys,.
I have a requirement that i want to be viewing the two column values in a single as column... values year & product will be exposed in a unique column values
Kind regards
Sree
Karthickumar Pillaiyarsamy yours is a database, in OBIEE is similar with some limitations...
Sree! you have 2 ways to do this: by using the CONCAT function or the | operator, examples here are 2 concatenating year, a space and production:
"Time". "" T05 annually name | ' ' || ' 'Products ' '. Product P1.
CONCAT ("Time". "T05 per year of name', CONCAT (" ","Products".)" P1 product"))
CONCAT in OBIEE accept only 2 params, so you if want to add a space between the 2 items, you must nest your function call.
In case your year column is a number, you can convert it to a string using CAST ("your column" as VARCHAR (10)).
-
Insertion of records in two different tables at the same time?
Hello everyone, I have question about inserting records in two different tables at the same time, I'm looking for is by the way a unique id, which is created in the first statement insert to the second insert statement. Example of this problem:
< cfquery name = "addRecords1" datasource = 'test' >
Insert Into Table1 (name, Date, age)
Values (< cfqueryparam cfsqltype = "cf_sql_char" value = "#arguments.) "Name # ' >.
< cfqueryparam cfsqltype = 'cf_sql_date' value = '#arguments. "Date # ' >.
< cfqueryparam cfsqltype = "cf_sql_int" value = "#arguments. Age #"(>); "
Select SCOPE_IDENTITY() as RecID;
< / cfquery >
< cfquery name = "addRecords2" datasource = 'test' >
Insert into Table2(Company,City,Date,ID)
Values (< cfqueryparam cfsqltype = "cf_sql_char" value = "#arguments.Company #" >,)
< cfqueryparam cfsqltype = "cf_sql_char" value = "" #City # ">,"
< cfqueryparam cfsqltype = 'cf_sql_date' value = "" #Date # ">,"
( < cfqueryparam cfsqltype = "cf_sql_int" value = "How to pass RecID to insert in this table?" >).
< / cfquery >
In this example, I'm inserting records in table 1 and creation of IDENTITY SCOPE as RecId. I would like to pass this id and insert it in my table 2. This Id, I'll use in my second table as an identifier. If anyone knows anything about this please let me know. Thank you.
); QueryName - DOT - ColumnName, so it should be:
); HTH,
^_^
-
Input data match with two columns in a table
Hello
I want to find records where the input data (> 100 records) are adapted to the two columns of the table
See below
with t as
(select 1 as id, 101 as num 'ram' that pat from dual
Union
Select 2 102, 'tom' from dual
Union
Select 1 103, 'tom1' from dual
Union
Select 2 101, 'tom2' from dual
Union
Select 2 104, 'tom3' from dual
Union
Select 1 105, 'tom1' from dual
Union
Select 2 105, 'tom1' from dual
)
Select * from t
I want to find records from the 't' table where (id, num) will be (1 101, 2 102, 1, 105)
Output must be
ID num
1 101
2 102
1 105select * from t where (id, num) in ( (1,101), (2,102), (1,105) );
Or store the input in a temporary table values and use IN
select * from t where (id, num) in ( select col1,col2 from your_temp_table );
Published by: JAC on 20 may 2013 14:55
-
Single line based on two columns and a single column
Dear members,
I have a table that contains duplicate rows, for which a request should be able to extract the unique row in the table. Here the unique is not based on a single column, but it should be in two columns and also check on the uniqueness on a column.
create table addr (varchar2 (10) firstname, lastname varchar2 (10), area varchar2 (3));
insert into values addr ('bob', 'james', 1');
insert into values addr ('bob', 'james', 1');
insert into values addr ('harry', 'bert', ' 1');
insert into values addr ('jimmy', 'bert', ' 1');
insert into values addr ('sam', 'mac', '1');
insert into values addr ('sam', 'Knight', '1');
insert into values addr ('tom', 'sand', '1');
insert into values addr ("cat", "mud", "1");
The query output must contain 3 lines.
Bob - james
Harry - bert or jimmy - bert [or the other of them], but not both
-Mac or sam - Sam Knight [or the other of them], but not both
Tom - sand
Cat - mud
SELECT firstname, lastname as total area WHERE addr = '1' GROUP by firstname, lastname; It takes no duplication of single column...
Any suggestions...SQL> with t_data as ( select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all select 'bob', 'james', '1' from dual union all select 'harry', 'bert', '1' from dual union all select 'jimmy', 'bert', '1' from dual union all select 'sam', 'mac', '1' from dual union all select 'sam', 'knight', '1' from dual union all select 'tom', 'sand', '1' from dual union all select 'cat', 'mud', '1' from dual ) SELECT firstname, lastname, area FROM ( SELECT t.*, row_number() over(partition BY firstname order by 1) rn, row_number() over(partition BY lastname order by 1) rn1 FROM t_data t ) WHERE rn = 1 AND rn1 =1 ; FIRSTNAME LASTNAME AREA --------------- --------------- ---------- bob james 1 cat mud 1 jimmy bert 1 sam knight 1 tom sand 1 SQL>
Maybe you are looking for
-
Best sources of information?
interest rate zero in CNN, NYTimes or WasHinton Post stories about my 'news' on my phone application. Edit I tried and they are still the default news stories. How can I get rid of this junk?
-
Equium A60-199: question on the colors of the button power/powerlight
I was wondering if someone could explain why the power button on my Equium A60-199 changed from its usual blue to a Pink/Purple mix, and also why usually green power light on the front of the laptop has changed to amber. Thank you.
-
HP envy 17-j130ea: hp envy 17-j130ea graphics card upgrade
I have the HP ENVY 17 t-j130ea running windows 8.1 with i7-4700MQ processor and 12 GB of ram. Currently I have the graphics nvidia Gforce740M - 2 GB but its still slow for a few games, so I want to replace by GTX 780 m coming 780Ti GTX 4 GB or 4 GB.
-
How can I put my taskbar on the bottom of my screen as attached on top?
How can I put my task bar which is usually on the bottom of the screen back issue now, is at the top of the screen?
-
Original title: out of memory at line 17 Using Vista system op on an old HP Pavilion of 3 year. Recently, an "out of memory at line 17" message keeps popping up and - web pages and files DO NOT OPEN, with browsers scrolling forever. Help, please