Query to select other records and then the same in 2 tables
Dear all,My database is 10 gr 2 and OS is Linux.
I have 2 tables with the same fields and almost the same data. There are just a few different lines in table 1 and table 2 that do not match each other.
I need to select these non-matching rows in both tables in a single request.
Kindly help on that.
Best regards, Imran
You have at LEAST two ways!
(SELECT * FROM table_A
minus
SELECT * FROM table_B)
union all
(SELECT * FROM table_B
minus
SELECT * FROM table_A)
/
For example:
SQL> create table table_a (col_1 number, col_2 varchar2(5));
Table created.
SQL> create table table_b (col_1 number, col_2 varchar2(5));
Table created.
SQL> insert into table_a values (1,'A');
1 row created.
SQL> insert into table_a values (2,'B');
1 row created.
SQL> insert into table_b values (1,'X');
1 row created.
SQL> insert into table_b values (2,'Z');
1 row created.
SQL> insert into table_a values (3,'C');
1 row created.
SQL> insert into table_b values (3,'C');
1 row created.
SQL> commit;
Commit complete.
SQL>
SQL> select * from table_a minus select * from table_b
2 union all
3 select * from table_b minus select * from table_a
4 /
COL_1 COL_2
---------- -----
1 X
2 Z
SQL> (select * from table_a minus select * from table_b)
2 union all
3 (select * from table_b minus select * from table_a)
4 /
COL_1 COL_2
---------- -----
1 A
2 B
1 X
2 Z
SQL>
Hemant K Collette
Tags: Database
Similar Questions
-
photos has not been loaded for weeks (usually the browser chrome on PC windows at work). I tried now on some other computers and get the same error message and I report every time. is there anything I can do or just wait for someone to fix it?
If you want any help here, you'll have to tell us what the error message.
Which report you errors to?
-
Can I also install Windows 7 on my other pc and we the same product key?
I have a genuine copy of windows 7 and install it on my pc, I can also install it on my other pc and we the same product key. My other pc needs a clean install and has its own product key on his windows 7 can I use this key after installation, any help would be great
Original title: installation of Windows 7
No, the key that can be used with 32-bit or 64-bit Windows 7 is exclusively for use with the disc 1. You cannot use install both. 1 license, 1 installation, so choose wisely. If you want to install Windows 7 32 or 64 bit on another partition or another computer, you must purchase an additional license.
INSTALLATION AND USE RIGHTS.
a. one copy per computer. You can install one copy of the software on a single computer. This computer is "licensed computer.
b. a computer license. You can use the software on up to two processors of the computer under license at some point. Except as provided in these license terms, you cannot use the software on any other computer.
c. number of users. Except as provided in these license terms, only one user may use the software at a time.
d. other Versions. The software may include several versions, such as 32-bit and 64-bit. You may install and use only one version at a time.
Where can I still get Windows 7?
Full version-
Microsoft Windows 7 Home Premium
Full version-
Full version-
Microsoft Windows 7 Professional
Version upgrade-
Microsoft Windows 7 Professional upgrade
Version upgrade-
Microsoft Windows 7 Ultimate Upgrade
Version upgrade-
Microsoft Windows 7 Home Premium Upgrade
Family Pack:
Microsoft Windows 7 Home Premium Upgrade Family Pack (3 users)
-
Stuck on a sql query to search for records that have the same parent child records
Oracle 10 g 2 Enterprise Edition.
Hello
I'm writing a logic to find records in a parent table, who have the same values in a child table.
This is part of a larger application, but I am stuck on that part for now, so I have mocked some of the below simplified tables to capture the heart of the
the problem is that I'm stuck.
Let's say I have a responsible parent, child employee table table and there are a number of many relationships between them.
The aptly named Join_Table manages the relationship between them. If a manager can manage several employees, an employee can be managed by
many managers.
I have a feeling it's stupidly easy, but it seems to me having a bad episode of brain freeze today!
If I ask for Manager John, so I want to find other managers who manage the exact list and even employees.-- parent table CREATE TABLE manager ( id number primary key, name varchar2(100)); -- child table CREATE TABLE employee ( id number primary key, name varchar2(100)); -- link table CREATE TABLE join_table ( manager_id NUMBER, employee_id NUMBER, CONSTRAINT join_table_pk PRIMARY KEY (manager_id, employee_id), CONSTRAINT manager_fk FOREIGN KEY (manager_id) REFERENCES manager(id), CONSTRAINT employee_fk FOREIGN KEY (employee_id) REFERENCES employee(id) ); -- Insert some managers INSERT INTO manager (id, name) VALUES (1, 'John'); INSERT INTO manager (id, name) VALUES (2, 'Bob'); INSERT INTO manager (id, name) VALUES (3, 'Mary'); INSERT INTO manager (id, name) VALUES (4, 'Sue'); INSERT INTO manager (id, name) VALUES (5, 'Alan'); INSERT INTO manager (id, name) VALUES (6, 'Mike'); -- Insert some employees INSERT INTO employee (id, name) VALUES (101, 'Paul'); INSERT INTO employee (id, name) VALUES (102, 'Simon'); INSERT INTO employee (id, name) VALUES (103, 'Ken'); INSERT INTO employee (id, name) VALUES (104, 'Kevin'); INSERT INTO employee (id, name) VALUES (105, 'Jack'); INSERT INTO employee (id, name) VALUES (106, 'Jennifer'); INSERT INTO employee (id, name) VALUES (107, 'Tim'); -- Insert the links -- John manages Paul, Simon, Ken INSERT INTO join_table (manager_id, employee_id) VALUES (1, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (1, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (1, 103); -- Bob manages Paul, Simon, Kevin, Jack INSERT INTO join_table (manager_id, employee_id) VALUES (2, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 104); INSERT INTO join_table (manager_id, employee_id) VALUES (2, 105); -- Mary manages Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (3, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (3, 107); -- Sue manages Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (4, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (4, 107); -- Alan manages Paul, Simon, Ken, Jennifer, Tim INSERT INTO join_table (manager_id, employee_id) VALUES (5, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 103); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 106); INSERT INTO join_table (manager_id, employee_id) VALUES (5, 107); -- Mike manages Paul, Simon, Ken INSERT INTO join_table (manager_id, employee_id) VALUES (6, 101); INSERT INTO join_table (manager_id, employee_id) VALUES (6, 102); INSERT INTO join_table (manager_id, employee_id) VALUES (6, 103); -- For sanity CREATE UNIQUE INDEX employee_name_uidx ON employee(name);
Answer should be Mike.
If I ask for Manager of Mary, the answer should be Sue.
This query will give me the list of managers who manage some of the same employees as John, but not the same employees accurate...
I thought about using set operations to find managers with a list of employees less than my employees is null and where my employees under their list of employees is null. But there must be an easier way more elegant.SELECT DISTINCT m.name AS manager FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND e.id IN ( SELECT e.id FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND m.name = 'John') ORDER BY 1;
Any ideas?
BTW, I need to run as a batch on tables with > 20 million rows so the efficiency of queries is key.What about...
WITH manager_list AS ( SELECT name, LTRIM(MAX(SYS_CONNECT_BY_PATH(id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees FROM (SELECT m.name, e.id, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id AND m.name = :P_MANAGER) GROUP BY name CONNECT BY prev = PRIOR curr AND name = PRIOR name START WITH curr = 1 ), all_list AS ( SELECT name, LTRIM(MAX(SYS_CONNECT_BY_PATH(id,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees FROM (SELECT m.name, e.id, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr, ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev FROM manager m, join_table jt, employee e WHERE m.id = jt.manager_id AND jt.employee_id = e.id) GROUP BY name CONNECT BY prev = PRIOR curr AND name = PRIOR name START WITH curr = 1 ) SELECT a.* FROM manager_list m, all_list a WHERE m.employees = a.employees
Would be easier in 11g, but I do not have a facility here so this is based on 10g.
See you soon
Ben
-
Why downloads sometimes fail, and then the same file fails
I just took to the part where I have to choose update of an article.
So, I choose the Update command.
But about 3 to 5 times, the download of the file fails.
But this doesn't seem to have anything to do with the content of the file like 20 minutes later, the download works fine.
So my question is why downloads sometimes fail and sometimes sail right through.
And why, when they try to download, my network connection is a turtle.
Welcome to the world of DPS. It can be frustrating to both.
-
I'm trying to adapt Windows to my new MacBook Pro with OS El Capitan.
I work remotely for a company and I want to connect my Mac to the server of the company.
My question is how to connect a MAc to a network drive with the permanently available connection. For example, in my old HP I went to my computer / connection to a network drive. I've selected a letter and note the name of the server that I wanted to be connected to. The connection was then shown with my other drive hard 'sections '; I want to say C:, D: (for recovery), e: (for tools) and then connecting to the external server has been shown with the selected letter.
There is no "letter" under OS X. It's a hangover very old of BACK, devices of mapping and volumes labeled mailbox.
If you are connected to your corporate network, you should see the available network volumes listed in the Finder, in ' my computer > network ", or with the command K to connect to a server.
You can create an alias for the volume and put it in the Dock, or leave on the desktop or put it somewhere else, and the next time you want to connect to this subject, simply double-click on it. You can also add the server address to your "favourites" in the connect to Server dialog box.
-
Press and hold Ctrl/Alt, then press on delete, and select Start Task Manager, and then the small black box appears and then disappears. How can I fix the Task Manager?
Hello
See if that helps you.
"The problems of Task Manager.
http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-Task-Manager-problems
See you soon.
-
Start my computer, it will default to the CTRL ALT DEL screen. After graduating in the login screen I enter the password. Windows will start and then the screen starts flashing and the screen say Logging Off, then restore the screen to the CTRL ALT DEL I can boot into safe mode. All other functions will not work.
Thank you
I guess you wanted to ask how to solve the problem. If then all in Safe Mode you can use system restore to set up Windows to a point when the problem did not exist.
-
Selection of records based on the flag
Hi all
I have records as follows:
Program name Effective_Date Valid_Flag
N 10/02/2012 ABCD
N 14/02/2012 ABCD
ABCD 20/02/2012 Y
N 01/03/2012 ABCD
N 10/03/2012 ABCD
ABCD 14/03/2012 Y
N 25/03/2012 ABCD
N 26/03/2012 ABCD
N 27/03/2012 ABCD
N 28/03/2012 ABCD
N 29/03/2012 ABCD
ABCD 25/04/2012 Y
I have to write a select statement to keep the first record and then only pull records when the Valid_Flag has changed. The result set should be as below.
Program name Effective_Date Valid_Flag
ABCD 10/02/2012 N - I kept the first record
20/02/2012 ABCD is - Valid_Flag chages to a Y for the first time and so on.
N 01/03/2012 ABCD
ABCD 14/03/2012 Y
N 25/03/2012 ABCD
ABCD 25/04/2012 Y
If there is no change in the flag, I don't have to draw from this record. Please help with suggestions of SQL. Thanks for your time and your help.ssk1974 wrote:
Hi allI have records as follows:
Program name Effective_Date Valid_Flag
N 10/02/2012 ABCD
N 14/02/2012 ABCD
ABCD 20/02/2012 Y
N 01/03/2012 ABCD
N 10/03/2012 ABCD
ABCD 14/03/2012 Y
N 25/03/2012 ABCD
N 26/03/2012 ABCD
N 27/03/2012 ABCD
N 28/03/2012 ABCD
N 29/03/2012 ABCD
ABCD 25/04/2012 YI have to write a select statement to keep the first record and then only pull records when the Valid_Flag has changed. The result set should be as below.
Program name Effective_Date Valid_Flag
ABCD 10/02/2012 N - I kept the first record
20/02/2012 ABCD is - Valid_Flag chages to a Y for the first time and so on.
N 01/03/2012 ABCD
ABCD 14/03/2012 Y
N 25/03/2012 ABCD
ABCD 25/04/2012 YIf there is no change in the flag, I don't have to draw from this record. Please help with suggestions of SQL. Thanks for your time and your help.
In the future, it would be nice if you could provide the sample data as below, I created.
ME_XE?with data as 2 ( 3 select 'ABCD' as col1, to_date('2/10/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 4 select 'ABCD' as col1, to_date('2/14/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 5 select 'ABCD' as col1, to_date('2/20/2012', 'mm/dd/yyyy') as col2, 'Y' as col3 from dual union all 6 select 'ABCD' as col1, to_date('3/01/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 7 select 'ABCD' as col1, to_date('3/10/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 8 select 'ABCD' as col1, to_date('3/14/2012', 'mm/dd/yyyy') as col2, 'Y' as col3 from dual union all 9 select 'ABCD' as col1, to_date('3/25/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 10 select 'ABCD' as col1, to_date('3/26/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 11 select 'ABCD' as col1, to_date('3/27/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 12 select 'ABCD' as col1, to_date('3/28/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 13 select 'ABCD' as col1, to_date('3/29/2012', 'mm/dd/yyyy') as col2, 'N' as col3 from dual union all 14 select 'ABCD' as col1, to_date('4/25/2012', 'mm/dd/yyyy') as col2, 'Y' as col3 from dual 15 ) 16 select * 17 from 18 ( 19 select 20 col1, col2, col3, 21 lag(col3) over (partition by col1 order by col2 asc) as last_flag 22 from data 23 ) 24 where last_flag != col3 25 or last_flag is null; COL1 COL2 COL LAS ------------ -------------------------- --- --- ABCD 10-FEB-2012 12 00:00 N ABCD 20-FEB-2012 12 00:00 Y N ABCD 01-MAR-2012 12 00:00 N Y ABCD 14-MAR-2012 12 00:00 Y N ABCD 25-MAR-2012 12 00:00 N Y ABCD 25-APR-2012 12 00:00 Y N 6 rows selected. Elapsed: 00:00:00.08 ME_XE?
See you soon,.
-
I want to play a full album, but no matter the song of the witch I start on after it is made to play this song it jumps to the next album (by the artist). and then the next album, I want to hear played very well. Shuffle seems to be disabled. Jump then dragging seems to be disabled. Not only this one album. It seems to do that. Thanks for your help. -Nick
Select all the tracks in the album. -Click right/option. Click check selection on the shortcut menu.
TT2
-
original title: HELP ME PLEASE!
(I am running windows xp) I need help! I tried installin linux ubuntu for netbook 10 on my msi u100, but everything was wrong when my little brother from my FlashDrive from the port, it has been installin linux from. so now when I turn on my computer it will not load windows, it will just have the msi logo and then the screen goes black and it does not load windows xp.
Netbooks and also most computers these days, do not come with an installation CD. Instead, it has a recovery partition. Assuming that you have not deleted the recovery partition,
Take a look at this:
http://randompastime.blogspot.com/2010/02/restoring-MSI-wind-U100-NetBook-to.html
Hope this helps
Post back if necessary
__________________________________________________________
If this post can help solve your problem, please click the 'bookmark' or 'Yes' to this message button. Marking a post as answer, or relatively useful, you help others find the answer more quickly.
-
When I try to "save under" I get a message "Initalising the root folders to display" and then the screen freezes. Sometimes when I click several times on the target folder it opens other times it does not. Any thoughts?
Hello
You try to save files using Microsoft office?
If so, this article should help you
The program stops responding when you try to open or to save a file in an Office 2002 program, in an Office 2003 program, in a 2007 Office program or in a program Office 2010
http://support.Microsoft.com/kb/313937
If its with a different program and then check if the problem exists in Safe Mode, if the computer works as expected in mode without failure, then we can solve the problem in the clean boot state.
Step a. refer to the article below for the procedure safe mode in Windows XP
A description of the options to start in Windows XP Mode
http://support.Microsoft.com/kb/315222
Step b. You need to perform a clean boot to find the program that is causing and then disable or remove.
How to configure Windows XP to start in a "clean boot" State
http://support.Microsoft.com/kb/310353/en-us
Note: When you are finished troubleshooting, follow the steps as explained in the article to reset the computer to start as usual.
Visit our Microsoft answers feedback Forum and let us know what you think.
-
My sidebar is not displayed in my administrator account. A pop-up Windows says 'settings.ini is being used by another process. Close other programs, and then click Retry. "However, no other program does run I know. I'm not able to access using Windows, the window is empty and shows that the site is under construction. Internet access seems to be hampered. This problem is not on my user account on the same computer, and I saw Windows Help on my user account. Also I tried to do a system restore and it was unsuccessful both times.
The profile of the user of this account may be damaged. You must create two new accounts administrator and use one to copy the data from your current account to the new account on the other.
http://Windows.Microsoft.com/en-GB/Windows-Vista/fix-a-corrupted-user-profile
I managed to fix this time by running the Fixit http://support.microsoft.com/kb/886549
Some of the registry keys that repairs this Fixit seemed to have been corrupted by a facility in need of elevation on behalf of administrator halfway through user account. It is interesting to try everything first to see if that fixes it. I always keep a few spare administrator accounts available now.
-
Also, when I connect to my Windows 7 PC and try to open the gadgets I get error indicating:
Settings.ini is being used by another process. Close other programs, and then click Retry, or click Cancel to exit.
My start > search function does not work either. However, the two functions, and gadgets and start > search, work under different user accounts.
Someone saw on how to solve this problem?
I don't know if it's related, but Thunderbird 3 has stopped working as well. UGH!
For any question on Windows 7:
http://social.answers.Microsoft.com/forums/en-us/category/Windows7
Link above is Windows 7 Forum for questions on Windows 7.
Windows 7 questions should be directed to the it.
You are in the Vista Forums.
See you soon.
Mick Murphy - Microsoft partner
-
When I run defrag, an IE window opens and closes and a file download-security warning comes up and asks me to run or save the file name: c:\windows\system32 dfrgui.exe, if I hit then another warning of IE - sec stands up and says 'the Publisher could not be verified. Are you sure that you want to run. I struck and the loop repeats. I run a diag of the F10 boot menu with dell. They say that its software and non-material, pay! Microsoft says that Dell is responsible. Other programs to do the same thing. I've updated and rerun my AVG security without error. We are automatically updated, and no other programs were added. Please help me fix this loop? SOS?
Vista - open file - security warning
http://www.Vistax64.com/Vista-security/125044-open-file-security-warning.htmlHow to repair the operating system and how to restore the configuration of the operating system to an earlier point in time in Windows Vista
http://support.Microsoft.com/kb/936212/#appliesToHow to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
http://support.Microsoft.com/default.aspx/KB/929135Your programs launch properly from Safe Mode? Or Normal Mode if you create another user to test with?
Vista advanced boot options
http://Techblissonline.com/Vista-advanced-boot-options/Try running ChkDsk to check your drive for errors. Right click on your drive icon / properties / tools / error checking. Try first by checking do not each box (that it will run in read-only mode) to see if it reports any problems file or hard drive. If so, restart it by checking both boxes and restart to allow him to attempt to fix any problems found.
I see a lot of recommendations here for programs such as -
Malwarebytes' Anti-Malware
http://www.Malwarebytes.org/MBAM.phpSuperAntispyware
http://SUPERAntiSpyware.com/
Maybe you are looking for
-
Is there a function to allow me to mark messages for follow-up?
-
Satellite P200 - removal / cutting of WebCam
Hello I work in the offshore waters in the United Arab Emirates United & just bought a P200 - with a built-in webcam. Unfortunately, I was not allowed to take the laptop to the large - due to not power cameras - at all. I was aware of the ban on phon
-
WANT 4512: IPHONE PHOTO IMPRESSION 6
WHEN YOU TRY TO PRINT PHOTOS FROM MY IPHONE 6 I CAN'T CHANGE THE FORMAT OF 4 X 6 PAPER. THE ONLY OPTION IS TO LETTER SIZE.
-
How to compress the folders of outlook express
My Inbox Outlook express is almost complete (~ 2 GB) and continues to receive new e-mails. I tried to use the function of compression under file. It started OK, copy of the file and compression, then an error msg pops up saying that the file is used
-
c ++ updates today was wrong, now the browsers don't work-how to fix?
y (chrome and ie) browsers do nothing now after installing the recommended update today on my netbook (XP). In addition, all the news from the Media Player library are missing. I can't get on the net to understand what to do, or reinstall, or whatev