Vishal Mailinglist <list-p2Y/[EMAIL PROTECTED]> wrote:
Hi ,

I knew I was not explaining better.

sno | id | amount
1    | 1 |  200
2    | 1 | 300
3   |  2 | 100
4  | 2 | 100
5 | 1 | 500

how could I subtract the sno 1 id 1 and sno 2 id 1 amount .

select
    (select amount from tableName where sno=1 and id=1) -
    (select amount from tableName where sno=2 and id=1);


What if I do not have control over sno i.e it is  random or
unpredictable , I want to subtract it in order of occurrence. Like
doing subtracion of sno 2 and 5 and so on may be next occurance for
id 1 is at sno 20 , then what.

I don't understand what you are trying to achieve. What would be the correct output on your example?

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to