Difference between queries



IBM's flagship relational database management system

Difference between queries

Postby Shakthivel V » Sun Nov 07, 2010 12:04 pm

Hi ,


I need to findout difference between 2 queris.

For example:

Query 1 : select * from emp where emp_id=19 returns 10 records

Query2 : select * from dept where dept_id=10 returns 15 records. Both the tables have same records. i need the differnce of 5 records?
Shakthivel V
 
Posts: 22
Joined: Thu Mar 04, 2010 12:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: Difference between queries

 

Re: Difference between queries

Postby enrico-sorichetti » Sun Nov 07, 2010 1:22 pm

what kind of question is this :?

select * from emp where emp_id=19 returns 10 records
select * from dept where dept_id=10 returns 15 records


for what reason do You pretend that...
two completely unrelated queries to two completely unrelated tables
should give the same result :shock:

Both the tables have same records. i need the differnce of 5 records?

???
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Difference between queries

Postby dick scherrer » Sun Nov 07, 2010 10:07 pm

Hello,

what kind of question is this
A beginner/student question :)

@Shakthivel V
It is extremely important to use proper terminology as well as clearly state your requirement or doubt. . .

Tables have rows not records.

select * from emp where emp_id=19 returns 10 records
Nearly always emp_id is the key to the table - why are there 10 emp rows with the same id? Is this a complete typo? Is dept_id really what is needed?

Are you trying to understand why the 2 queries return a different number of rows or are you trying to have the query return the value obtained by calculating the difference in the number of rows returned?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post