Once again i send the table data:
Code Period Value
c1 2004 22
c1 2005 10
c2 2005 15
c3 2005 20
c4 2005 15
c5 2005 5
c6 2005 30
c7 2005 25
c1 2006 5
c2 2006 15
c3 2006 40
c4 2006 30
From this I need the sum of values for period 2005 and codes c1+c2-c4-c5
(this is not constant its just an example there is lot of codes like this..)
For ex:- the reulst that I want to get is:
the value for code c1, period 2005 is 10
for code c2, period 2005 is 15
sum of c1 and c2 is 10 + 15 = 25
The value for code c4, period 2005 is 15
for code c5, period 2005 is 5
Sum of c4 and c5 is 15 + 5 = 20
Finally the result is (c1+c2) - (c4-c5) = 25 - 20 = 5
On 8/14/06, Chris <[EMAIL PROTECTED]> wrote:
VenuGopal Papasani wrote:
> Hi,
> i got a table datavalue as follows
> code period value
>
> c1 2005 1
> c2 2005 2
> c3 2006 3
> c4 2005 2
> c5 2005 1
now i need a query where some values should be added and some
> values should be subtracted of certain period.for ex here 2005 now i
need
> (c1+c2-c4-c5) can i do it in a single query .Can any one
give
> me the query plsssssssssss
sure.
select c1 + c2 - c4 - c5;
doesn't help you fix the problem because you haven't told us what the
criteria is for the query.