Compare Two Columns Relationship

Apr 29, 2011

I've a table (RelationshipX) with two columns with following values. The table represents the relationships. When I run the following query, It will give me all the combination of relationships...however, I need to get 15 unique as defined below.

Col1Col2
1106011060
1106011640
1106011142
1106011095
1106013029
1106014058

I run the following query to get below of all the combinaiton (note, I am opting out those six rows which matches to each other) select a.Col2 as Col1, b.Col2 as Col2 from RelationshipX a, RelationshipX b

where a.Col1 = 11060
and a.Col1=b.Col1
and a.Col2 <> b.Col2
order by Col1, Col2
[code]....

HOW can I modify my SQl so I get only 15 unique relationship records. (For example two UNDERLINE rows are technically same, and there are total 15 of them)???.

View 1 Replies


ADVERTISEMENT

SQL & PL/SQL :: Compare Columns Of Two Table?

Apr 5, 2013

I need to compare columns of two tables in oracle 10g. If columns of both tables match with each other, then i need to create new table dynamically with matched column name and datatype. For example, table1 contains name, ID, Phone_no and address table2 contains name, Id, address, area and pincode. now , i need to create table3 which will contains name, ID,address, Phone_no, area and pincode as columns( I mean matched columns should not be repeated in table3). how to do this..

View 17 Replies View Related

SQL & PL/SQL :: To Compare Records In Two Columns

Oct 8, 2010

I need to compare records in the two columns (varchar). I need to find almost the same names from that columns.

For instance:
'MAPE STUD' <-> MAPE STUDY

And I should see that these records are the same because different is only in the one word.

View 31 Replies View Related

SQL & PL/SQL :: Compare 2 Tables On Columns Value?

Oct 25, 2010

I have to compare 2 tables on a columns's value.The 2 tables have same column as Regn_no.I just need to have the result in True Or False from a Query if the particular value of Regn_no is found in both the tables.

Temporarily I using a bit different and not good query which is as follows:

select count(*) from tab1 where regn_no in (select regn_no from tab2) and regn_no = 'UP78AN7890';

View 2 Replies View Related

SQL & PL/SQL :: Compare 2 Tables Based On 2 Columns

Oct 19, 2010

My tables looks like this:

Desc Table A (account)
Account1_id
Account2_id
name,
empid

Table B (Bill )
BillNo
Advertiserid
agencyid
total vvalue

I need to pick up total value from table B where the unique combination of advertiser-Agency id is the same as the given account1_id -Account2_id combination in table A for each employee id.

In other words my output should be like

Empid | Account_id (should be same as advertiserid)| Account2_id (same as agencyid) | sum(total_value) for this adv-agency combination.....

objective: Get the total value from table B for each unique account1-account2 combination (advertiser-agency in other words) .

I am not sure if I should use a correlated subquery or how to handle the situation....Right now I am just checking the two columns separately like this:

select.......from a,b
where b.advertiser_id = a.account1_id and b.agencyid = b.account2id

Is it correct to do so? I have a feeling that I am missing something if I join them separately like this.

View 3 Replies View Related

PL/SQL :: One To Many Relationship?

Oct 18, 2012

I want to know how many managers have employees under him?

I mean to say one manager may have multiple employees from employees table.

View 7 Replies View Related

PL/SQL :: Zero To Many Relationship

Mar 7, 2013

I have one RDBMS concept question.if i have 2 tables with 0 to many realtionship. can i create referential integrity constraint between them?

In other words how can i tell whether the records in table A(child table) are not orphan records and have 0 to many relationship with table B(parent table) ? Right not there is no constraint defined on both tables.

View 3 Replies View Related

Parent Child Relationship

May 13, 2011

Just wanted to pose a question Can a (Unique and Not nullable)Alternate key of the parent table be part of child Table in an Identifying relationship i.e part of primary key of a child table????

Is there a rule that a primary keys of a parent table can be used to build a identifying relationship with its child?

View 1 Replies View Related

Forms :: Multiple One To Many Relationship

Apr 27, 2010

I have a table which has 2 one to many relationships like a tree structure in the same table, is there a way that I can show the same on the form and be able to do the insert and update on the same table?

View 10 Replies View Related

Page 2 - (RELATIONSHIP) - Not Working?

Mar 6, 2011

Quote: Originally Posted by Silverj2k11

ALTER TABLE CONTRACT
ADD FOREIGN KEY (client_id)
REFERENCES client(client_id);

Didn't work! I am now losing my mind.

ORA-00904: "CLIENT": invalid identifier You do have a table named CLIENT?

View 7 Replies View Related

PL/SQL :: One To Many Relationship In A Query Via Join

Oct 11, 2013

I have been told to create a query which should give out the same output as the UI of an exception management application .  However , many referenced tables have one to many relationship . I created a query using a function which was giving the required output . But the performance of the query was not good as for each row . Is there a method to create a select using joins to show one to many relationship in a table .

View 4 Replies View Related

SQL & PL/SQL :: Parent Table Relationship

Feb 6, 2012

Would there be any problem / error when we import the dump file (which has parent table) on target database ?

View 11 Replies View Related

Relationship - Table Creation With Keys Looks?

Feb 24, 2007

the relationship on my script.What I want to do is make it possible to assign many courses to a student.But I have read a few books on foreign keys and primary keys, and I still dont get how to go on doing this....

This is how the table creation with the keys looks right now...

 CREATE TABLE CAMPUS (
   CAMPUSID            NUMBER(4) NOT NULL,
   NAME                VARCHAR2(80) NOT NULL,
   CONSTRAINT CAMPUS_PK PRIMARY KEY (CAMPUSID));

[code]...

View 3 Replies View Related

SQL & PL/SQL :: Creating Parent Child Relationship

Aug 8, 2011

I have a table called FAMILY which holda the data like , for father_gen_1 --->father_gen_2 --> father_gen_3 -- son.

father_gen_1 father_gen_2 father_gen_3 son
ABC XYZ GEF MNC
ABC lmn kth

I want to get the output which is a three column heirarical table and holds the parent child relationship Like following:-

id name parent_id
1 ABC NULL
2 XYZ 1
3 GEF 2
4 MNC 3
5 LMN 1
6 KTH 5

View 7 Replies View Related

SQL & PL/SQL :: Display Hierarchical Relationship Between Tables?

Mar 5, 2010

i'm trying to display the hierarchical relationship between the tables (parents-child-subchild).

[b]table structure[/b]
DEPT
|PK-DEPT_ID
|
EMP
|pk-EMP_ID
|fK emp_DEPT_fK((FK column is dept_id references dept table dept_id column))

[code]....

but by using below query i am not getting complete heirarichy.

SELECT LEVEL,
Table_Name,
Constraint_Name,
R_Constraint_Name ,
SYS_CONNECT_BY_PATH(Table_Name, '/') Path

[code]....

View 2 Replies View Related

SQL & PL/SQL :: Delete - Parent / Child Relationship

May 22, 2012

I have a DB that has one parent table with many child tables. I would like to delete all records(child - parent) based upon a particular "net_id". I have three versions that "seem" to work BUT I'd like to use "version2" because I want to go to the parent one time(for the parent delete I just made it simple for me) only and be able to delete the child record(s) from the child table(s). I want to achieve this w/o using triggers...

My question: Is version2 an "ok" way to delete child records or should I try another method(version1 or 3)??

create table PARENT
(
event_id NUMBER,
event_title VARCHAR2(50),
net_id VARCHAR2(16)
);

--truncate table parent;
insert into parent
(event_id, event_title, net_id)
values
(1, 'title1', 'CURLY');
[code]...

View 10 Replies View Related

How Is Relationship Between MEMORY_TARGET And SGA_MAX_SIZE Parameters

Jun 28, 2012

I was just wondering how is the relationship between MEMORY_TARGET and SGA_MAX_SIZE parameters, if exists any at all.I set my memory parameters as:

# Enable AMM
MEMORY_MAX_SIZE=10G
MEMORY_TARGET=4G
# Disable ASMM
SGA_TARGET=0
SGA_MAX_SIZE=0

So I bounce my instances and when I checked the parameter SGA_MAX_SIZE, Oracle automatically set a value of 2456M to it:

sga_max_size big integer 2456M
sga_target big integer 0

Reading MOS ID 443746.1, there is no clear mention about this relationship. It seems that Oracle automatically set SGA_MAX_SIZE as 60% of MEMORY_TARGET.

In am running Oracle 11gR2 (11.2.0.2.3) under Red Hat Linux.

View 10 Replies View Related

PL/SQL :: Possible To Maintain Primary Key And Foreign Key Relationship

Nov 16, 2012

I have a requirement like below

I have 3 tables (Prospect,customer,user) and I have a contact_dtls table .

In prospect table Prospect_id is the primary like this customer_id in customer table and user_id in the user table

in the contact_dtls table I have a column contact_id and other cols.The contact_id can be from prospect_id,customer_id and user_id in other words we can tell the prospect can be a contact or the customer can be a contact and the user also can be a contact also.

Now the question is "is it possible to maintain primary key and foreign key relationship with this design that means the prospect_id,customer_id and user_id would be the foreign keys to the contact_dtls table.

View 3 Replies View Related

Forms :: Tab Canvas - Master / Detail Relationship

Feb 21, 2012

I have a form that contains a tab canvas. On the second canvas page I have two data blocks with a master detail relationship.The first block (master) is driven by a table (table_one) with the following fields:

sf_id (PK)
sf_code - VARCHAR2(40)
sf_desc - VARCHAR2(250)

The second block (detail) is a repeating block driven by a table (table_two) with the following fields:

error_code - VARCHAR2(40
error_code_desc - VARCHAR2(250)
is_major_error - VARCHAR2(1)
error_type - VARCHAR2(1)
error_is_active - VARCHAR2(1)
update_date - DATE
sf_id (FK - table_one.sf_id)

The second block only shows error_code and error_code_desc. The point of this canvas page is to add/remove master records and associate detail records with a master. I never want to actually insert or remove records from table two; merely updating the sf_id column in table two.What I am trying to achieve is the following:

1. Create a master record with detail records at the same time.
2. Delete a master record
3. Add and remove detail records

An insert into the detail block is nothing more than associating a master record with a detail record by updating the sf_id column in table two. A delete from the detail block is nothing more than setting the sf_id column to null in table two. I am not actually adding or removing records in table_two.

I have tried overriding the commit on the second block to perform updates instead of Oracle actually trying to insert NEW records into table_two.

View 2 Replies View Related

Forms :: Master-Detail Relationship In Oracle

Mar 27, 2010

I'm designing a canvas which will open up on the click of a push-button from a form A. Now this form A has a data block(ie. single underlying table A).

I want to display data from two tables - Table B and Table C in this canvas in the form of a multi-record grid structure - one below the other i.e. table B data above and table C data below.

Now table B and table C share a PK-FK relnship between them. What I want is when a user clicks on a record in the table B above then the corresponding records in the table C should get displayed below(now there can be multiple detail records in table C for a single record in table B - PK-FK reln)

i'd written code something like this in the When-button-pressed trigger:-

c_where_clause := ....(query from Form A)
set_block_property('block B',default,c_where_clause);
go_block('block B');
go_block('block C');
execute_query;
first_record;

(in addition to the above trigger, I have also included queries in the post-query trigger of the two tables B and C to get some data populated in the non-database fields in this canvas)

do i have to do add a piece of code to loop thru the records...like checking for last record,if not going to the next_record and so on for both the blocks?

View 1 Replies View Related

SQL & PL/SQL :: Procedure To Get Path From Parent-child Relationship?

Apr 23, 2010

I have a table which uses parent-child relationship to store the options available. I need a procedure to give me the full path given the id of a particular option.

I have two different functions. One of them uses the Oracle built in function and the other uses simple queries with a loop.The code of the functions are given below.

Now, the problem is with their "performance". The difference in their performance is significant. The function using the Oracle function takes more than 2 hours to run a query whereas the other function takes less than 2 minutes.

I am having trouble trusting the other function. No matter how many tests I perform on the output of both the functions, it always comes out to be the same.

Function 1
=====================
FUNCTION Gettree (opt_id IN NUMBER,i_app_id IN NUMBER)
RETURN VARCHAR2
IS
path VARCHAR2(32767);
application_no NUMBER;
BEGIN

[code]...

View 2 Replies View Related

SQL & PL/SQL :: ORA-02291 Parent / Child Relationship Error

Jan 4, 2012

I am working on a project, the insert statement is not functioning properly and I cannot find the error The error is in the insert statement for CustOrder. The error states that NULL cannot be inserted into CustOrder.CustID. I have declared CustID and its reference. I have looked over the code several times and I cannot find the problem.

If it makes a difference I am using APEX. The company has not database or program to work with a database so I am building everything from scratch.

declare
l_CustOrderID number;
l_CustID number := :P11_CustID;
begin

[code]....

View 25 Replies View Related

Forms :: How To Programmatically Change Relationship In Master-detail Block

Dec 20, 2012

can we use set_block_property to program to switch multiple relationships. for example

if true then use relationshipA
else relationshipB
end if;

View 9 Replies View Related

Performance Tuning :: Relationship Between Buffer Cache And Busy Waits

Oct 3, 2010

Is there any relationship b/w tuning BUFFER CACHE and BUFFER BUSY WAITS?

1) Buffer Busy Waits are happening as the User process found the same Datablock is being used by another user in the BUFFER CACHE.
2) And also happens, when the server process found the same Datablock are being used in the Datafile.

View 5 Replies View Related

Forms :: Hierarchical Tree In Oracle - Parent Child Relationship

May 14, 2010

I have data in a table which don't have parent child relation ship. Can I display the data in that table in hierarchical tree item in a form.

Is it a must that data should have parent child relationship to display them in hierarchical tree item in a form.

View 1 Replies View Related

Reports & Discoverer :: Create A Report By Using One Field / Text As Columns Name In Layout But Display All Columns

Jun 16, 2010

I want to create a report by using one field and one text as columns name in layout but display the all the columns. I mention the 5 column names in query.how can I write function in summary column.

View 4 Replies View Related

Performance Tuning :: Index 15 Columns When Cannot Predict Columns Will Be Used In Where Clause?

Apr 4, 2011

I am running a fairly busy Oracle 10gR2 DB, one of the tables has about 120 columns and this table receives on average 1500 insertions per second. The table is partitioned and the partitioning is based on the most important of the two timestamp columns. There are two timestamps, they hold different times.

Out of these 120 columns, about 15 need to be indexed. Out of the 15 two of them are timestamp, at least one of these two timestamp columns is always in the where clause the queries.

Now the challenge is, the queries we run can have any combination of the 13 other columns + one timestamp. In reality the queries never have more than 7 or 8 columns in the where clause but even if we had only 4 columns in the where clause we would still have the same problem.

So if I create one concatenated index for all these columns it will not be very efficient because after the 4th or 5th column the sorting would no longer be very useful and I believe the optimiser would simply not use the rest of the index. So queries that use the leading columns of the index in sequence work well, but if I need to query the 10th column the I have performance issues.

Now, if I create multiple single column indexes oracle will have to work a lot harder to maintain all these indexes and it will create performance issues (I have tried that). Besides, if I have multiple single column indexes the optimiser will do nested loops twice or three times and will hit only the first few columns of the where clause so I think it will kind of be the same as the long concatenated index.

What I am trying to do is exactly what the Bitmap index would do, it would be very good if I could use the AND condition that a Bitmap index uses. This way I could have N number of single column indexes which the optimiser could pick from and serve the query with exactly the ones it needs. But unfortunately using the Bitmap index here is not an option given the large amount of inserts that I get on this table.

I have been looking for alternatives, I have considered creating multiple shorter concatenated indexes but this still would not address the issue since many queries would still not be served properly and therefore would take a very long time to complete.

What I had in mind would be some sort of multidimensional index, I am not even sure if such thing exists. But essentially it would be some sort of index that could serve a query efficiently regardless of the fact that the where clause has the 1st, 3rd and last columns of the index.

So considering how widely used Oracle is and how many super large databases there are out there, this problem must be common.

View 12 Replies View Related

SQL & PL/SQL :: How To Select All Columns From Table Except Those Columns Which Type In Query

Jan 21, 2011

I have a two question.

Question 1:How to select all columns from table except those columns which i type in query

Question 2:How to select all columns from table where all columns are not null without type each column name which is in empty data

View 5 Replies View Related

How To Compare A Value In SQLLDR By Using WHEN

Feb 25, 2013

Can we compare in SQL *Loader control file by using WHEN Clause.I want to load the data when in_no greater than 1300000000. While running below control file i am getting error as:

SQL*Loader-350: Syntax error at line 5.
Illegal combination of non-alphanumeric characters
WHEN (in_no >= '1300000000')
Here is the control file.

ex:

Load Data
infile *
discardfile 'test_when.dsc'
truncate into table test_when
WHEN (in_no >= '1300000000')
fields terminated by ','
(a,b,c,
in_no)
[code]....

how to compare a value in sqlldr control file.

View 1 Replies View Related

SQL & PL/SQL :: Compare Two Different Table?

Jul 11, 2011

I want to compare two tables column by column and find out which columns are matching and inserting matching columns value into another table.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved