Fritz, add an autonumbered column at the beginning of your table.

Nummer Jahr       UJ1        UJ2
------ ---------- ---------- ----------
     1 2001          1
     2 2002          2
     3 2003          3
     4 2007          7
     5 2011         11
     6 2012         12
     7 2015         15
     8 2016         16
     9 2020         20

AUTONUM Nummer IN c1 USING 1,1 NUM
INSERT INTO c1 SELECT Jahr, UJ1 from .... WHERE ... ORDER BY Jahr ASC
UPDATE c1 SET UJ2 = t1.UJ1 FROM c1 t1, c1 T2 +
  WHERE t1.Nummer = (t2.Nummer - 1)

That should do the trick for you
Albert

On 13/07/2014 5:23 AM, Dr. Fritz Luettgens wrote:
Hi,

Jahr = YEAR
UJ1 = Turnover YEAR 1
UJ2 = Tumover YEAR2
Jahr, UJ1, UJ2 INTEGER for now
later:  UJ1, CURRENCY
years: do not run continuously up

A) Version 1
R>select * from c1
  Jahr       UJ1        UJ2
  ---------- ---------- ----------
        2001          1
        2002          2
        2003          3
        2007          7
        2011         11
        2012         12
        2015         15
        2016         16
        2020         20

Plan: To use a variable only (based on a function) to show in a form based
on (A) Version 1)  only
- always the "last" year with "last" turnover
- Turnover: 2007        7       Last Year: 2011         11
Problem: (example)   2001,2002,2003,2007,20011,...... is not always +1
(to explain the values see below B))

B) Version 2
Jahr       UJ1                    UJ2
  ---------- ----------         ----------
        2001          1
        2002          2         1
        2003          3         2
        2007          7         3
        2011         11         7
        2012         12         11
        2015         15         12
        2016         16         15
        2020         20         16

I tried all different functions like ....
UPDATE c1 SET UJ2 = UJ1 WHERE UJ1 = UJ1(IFLT(((Jahr -2)),(((Jahr -1)),((uj1
where Jahr = (Jahr -2)),((uj1 where Jahr = (Jahr -3))))
but I am not getting any near.

I am sure this is a problem known well before,
If anybody knows how to solve this riddle with a function, (like NEXT
"VALUE"  a.s.o on a column value - not autonumbered column)
please give a beginner a little hint :)

Thank´s

Fritz





Reply via email to