SELECT (t1.cnt1 + t2.cnt3 - t3.cnt11) FROM table
t1, table t2, table t3 WHERE t1.ColPoint=1 AND
t2.ColPoint=5 AND t3.ColPoint=2 AND t1.id=1 AND
t2.id=t1.id AND t3.id=t1.id

Of course, self joins can be expensive, this grows
in complexity as you need to add/subtract more
counts ,and this is not general.

--Bill


Morten Søndergaard wrote:

> i have a MySQL DB whit this tabel:
>
> Id  ColPoint  CntDateTime          Cnt1  Cnt2
> Cntx..... Cnt32
> 1    1          2001-08-01 00:05:00    12  14
> ....
> 2    1          2001-08-01 00:10:00    11  12
> ....
> 3    1          2001-08-01 00:15:00    10    9
> ....
> 4    1          2001-08-01 00:20:00    0    32
> ....
> 5    1          2001-08-01 00:25:00    6    4
> ....
> 6    1          2001-08-01 00:30:00    14  22
> ....
> 7    1          2001-08-01 00:35:00    11  17
> ....
> .
> .
>
> x1    2        2001-08-01 00:05:00    32    4
> ....
> x2    2        2001-08-01 00:10:00    31  22
> ....
> x3    2        2001-08-01 00:15:00    30  19
> ....
> x4    2        2001-08-01 00:20:00    0    22
> ....
> x5    2        2001-08-01 00:25:00    26  14
> ....
> x6    2        2001-08-01 00:30:00    24  22
> ....
> x7    2       2001-08-01 00:35:00    1  17  ....
>
> .
> .
>
> Ect.
> I am collecting data from 8 collecting points
> whit 32 counters each
>
> I have made a delphi program to show the data in
> bars or curves, but the
> uses shal
> have the opportunite to add and subtrach the
> datas
>
> Exampel for user 1
> ColPoint(Cnt1) +ColPoint5(Cnt3)
> -ColPoint2(Cnt11)
>
> How can i build a sql-string that satisfied this
> need
>
> ----
> ----------------------------------------------------------------
>
> 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

--
Bill Adams
TriQuint Semiconductor






---------------------------------------------------------------------
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