>What I want is to get next result:
>Col.B | Col.A | Desription not in result query
>A | -8 | -10-(-2)
>B | -2 | -3-(-1)
You need an ordering key; otherwise order is indeterminate. Still,
comparisons based on row sequence are often easier to code in the
application. A SQL hack is possible, but it may not perform very well.
If the ordering key is a column k which, following your example, takes
the values 1,2,3,4, and if your table follows the pattern of your
example, this query yields your desired result:
t1.a AS B,
(SELECT t2.a FROM tbl AS t2 WHERE t2.k=(t1.k-1)) AS delta
FROM tbl AS t1
If your MySQL version is pre-4.1, you could accomplish this with user
variables, but it would be messier.
> I have table with next data:
> Col.A | Col.B | Col.C
> -10 | A | D
> -2 | A | R
> -3 | B | D
> -1 | B | R
> What I want is to get next result:
> Col.B | Col.A | Desription not in result query
> A | -8 | -10-(-2)
> B | -2 | -3-(-1)
> I am trying for several days without any progress. Can anybody halp me?
> Actualy I Have a problem with result Col.A.
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.412 / Virus Database: 268.18.4/705 - Release Date: 2/27/2007