• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

query help?

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI every body
my case is:
i have rows in database like this:
-------------------------------------------------------------------

cust_id bene_id amt
------- --------- -------
1001 2001 1000
2001 1001 1200
1001 2001 500

so instead of doing three transfers , if go as a overall transfer,
we have to transfer from 1001 to 2001 300
so the query should return as

cust_id bene_id amt
------- --------- -------
1001 2001 300

so please help me how can we do this in a query.
 
author & internet detective
Posts: 42173
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mallik,
Rewording the problem another way, you want the sum of the records from 1001 to 2001 minus the sum of the records from 2001 to 1001.

Can you write a query for both parts of this? That would give you two queries. Then you could build up a larger query around them. The larger query would reverse the ids and negate the values via a nested table. (or stored proc if you are on the database end) Then you could do a query on the nested tables to get your answer.

Give it a shot slowly building it up as you go. Then you can post here when you get stuck.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic