If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > sum of counts of same data existing in 2 different tables

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-24-09, 23:44
joe robles joe robles is offline
Registered User
 
Join Date: Jun 2009
Posts: 10
sum of counts of same data existing in 2 different tables

Hi all,

There are two similar tables in 2 different schemas/databses that contain employee information.

I have a requirement to get the list of the emp ids from those two tables whose sum of the count in the above tables is less than or equal to a user defined value.

This is a wierd requirement but we need this for the data setup for one of our important performance tests.


Example:

Emp_ids 1, 2 and 3 exist both in table A and table B.

For emp_id 1, table A has 20 records for that emp_id and table B has 20 records => sum of counts = 40

For emp_id 2, table A has 40 records for that emp_id and table B has 40 records => sum of counts = 80

For emp_id 3, table A has 100 records for that emp_id and table B has 100 records => sum of counts = 100

User wants only those emp_ids whose sum of count from both tables is less than or equal to 80.

Thus the result of the sql must be emp_id 1 and 2 only.

How do I do that?

I tried few things but in vain.

Any help is appreciated.

Thanks in advance for your time and interest.

Last edited by joe robles; 07-24-09 at 23:47. Reason: duplicate posting by mistake
Reply With Quote
  #2 (permalink)  
Old 07-24-09, 23:53
joe robles joe robles is offline
Registered User
 
Join Date: Jun 2009
Posts: 10
Hi all,

Please ignore this post since this is a duplicate of the latest one. I ws not able to delete this posting.

Sorry for any inconvienence caused.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On