• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 41878
909
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic