On 26.02.2001 14:45:50 Dart wrote:

> Dear all,
> Sorry to ask question again, or maybe i am just a beginner.
>
> I wanna ask:
> If there are 2 records
> Name             Income      Out
> Data1               1000       700
> Data2                970        500
>
> If i want to have the output:
> Name              Income      Out      Balance
> Data1               1000          700       300
> Data2                970           500        770

SELECT Name, Income, Out, (Income - Out) AS Balance FROM Table WHERE Name
IN['Data1', 'Data2'];

Hmm, not to sure about the IN part - look it up *G*

Uh, just saw that:
> Data2                970           500        770

How is the balance calculated?  First I thought, that it is (Income - Out) - but
this gives 270, and not 770?  Or is it (1st (Income-Out) + 2nd (Income-Out))?
But no, this would only give 570.
Hmm, nevermind my SELECT statement above, it's probably wrong....



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to