473,395 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

compare data in two tables

5
I have two tables
emp - ( has two field)
Name Sal
Joe 45
Jack 50
Kate 67

Dept
Name Dept Sal
Joe IS 46
Jack IS 50
Kate IS 89


I need to write a query which gives in output the records whose column " sal " does not match
the other condition is that i can ignore the ones who Sal has a difference of just 1
in this case Joe has a difference of 1 so i shoudl not print that out.

Help me out in this

Thanks
May 11 '07 #1
2 2855
MMcCarthy
14,534 Expert Mod 8TB
I have two tables
emp - ( has two field)
Name Sal
Joe 45
Jack 50
Kate 67

Dept
Name Dept Sal
Joe IS 46
Jack IS 50
Kate IS 89


I need to write a query which gives in output the records whose column " sal " does not match
the other condition is that i can ignore the ones who Sal has a difference of just 1
in this case Joe has a difference of 1 so i shoudl not print that out.

Help me out in this

Thanks
This will only work if the Names are exactly the same.
Expand|Select|Wrap|Line Numbers
  1. SELECT emp.Name, emp.Sal, Dept.Name, Dept.[Dept], Dept.Sal
  2. FROM emp INNER JOIN Dept
  3. ON emp.Name = Dept.Name
  4. WHERE emp.Sal - Dept.Sal >1
  5. OR Dept.Sal - emp.Sal > 1
Mary
May 12 '07 #2
Looking to do something similar to this but the tables are in Different DB's?? I have the query working in Test like yours but can't figure out how to make it work across DB's?

I need to validate that Table 1/DB1 Feeder Number Exist in Table 2/DB2. If the valus is NOT in Table2/DB2 update flag to N in Table1/DB1

I am doing this using PL/SQL developer as tool....

Table 1 has 12 colums
table 2 has 25 colums
May 16 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Stephen | last post by:
I have to write a .Net application which can compare SQL Databases including things like: - DB structure, PK's, FK's, indexes and types of indexes i.e. should be able to detect if the same index...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
8
by: Vincent | last post by:
has any one seen a program to compare mdbs'. I have ran into a few of them, but none seem to really do that job. Basically what I need to do is, take 2 access mdb's and check the differences...
9
by: geronimo_me | last post by:
Hi, I am atempting to compare part of a field with the whole of another field in access. Is this possible? Basically I have 2 tables with the following info: Table1 Field1 = MR.
9
by: VMI | last post by:
I have two tables and I want to compare these two tables with a query( ie. "select * from A where B.key = A.key") and the result will be stored in a 3rd table (table C). is this possible? If...
1
by: Mark | last post by:
by m.r.davies I have 2 tables on seperate Db's (and servers) I want to use a datareader on the first table to pick the booking ref, and then use that booking ref to query the 2nd DB when i have...
0
by: Shaw | last post by:
Our database is constantly updated (input data) from another DB, and sometimes it crashes our ASP.NET applications. My boss told me to write a DB utility app to check DB and make sure all apps are...
5
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of...
6
by: napatel04 | last post by:
Hi everyone, I would like to know if there is a quick query someone can help me write for the following scenario. I think I can do this with VBA but since this is suppose to be a temp. solution,...
5
by: chazzy69 | last post by:
Ok heres what im trying to achive i am constantly updating the information in a table but know i what know if the data im replacing it with is new, i.e. whether or not i already had the data in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.