Dear Fritz

As SELECTs are ordered in time of visualization, you have first to say which 
order and fix that for time of comparison. 
So I would prefer a temporary table including an autonumber column

CREATE TEMPORARY TABLE tmpC1 ( LFNR   INTEGER, Jahr   INTEGER, UJ1 INTEGER)
-- And Insert now. Attention: This order fixes the Next-Follower!!
INSERT INTO TmpC1 (Jahr, UJ1) SELECT Jahr, UJ1 FROM c1 ORDER BY Jahr
AUTONUM LFNR IN tmpC1 USING 1 1 NUM

-- create values for previous year, similar to last example
CREATE temporary View vPreValues ( LFNR, UJ2) AS SELECT (LFNR+1), UJ1 FROM tmpC1

-- display
SELECT t1.Jahr, t1.UJ1 t2.UJ2 FROM tmpC1 T1 LEFT OUTER JOIN vPreValues t2 ON 
tmpC1.LFNR = T2.LFNR

t1.Jahr    t1.UJ1     t2.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

Best Regards
Adrian Huessy

> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[email protected]] Im Auftrag von Dr. Fritz
> Luettgens
> Gesendet: Sonntag, 13. Juli 2014 13:23
> An: RBASE-L Mailing List
> Betreff: [RBASE-L] - NEXT Value in a column 1,2,5,10
> 
> 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
> 
> --- RBASE-L
> =======================3D=======================
> D=
> TO POST A MESSAGE TO ALL MEMBERS:
> Send a plain text email to [email protected]
> 
> (Don't use any of these words as your Subject:
> INTRO, SUBSCRIBE, UNSUBSCRIBE, SEARCH,
> REMOVE, SUSPEND, RESUME, DIGEST, RESEND, HELP)
> =======================3D=======================
> D=
> TO SEE MESSAGE POSTING GUIDELINES:
> Send a plain text email to [email protected] In the message SUBJECT, put
> just one word: INTRO
> =======================3D=======================
> D=
> TO UNSUBSCRIBE:
> Send a plain text email to [email protected] In the message SUBJECT, put
> just one word: UNSUBSCRIBE
> =======================3D=======================
> D=
> TO SEARCH ARCHIVES:
> Send a plain text email to [email protected] In the message SUBJECT, put
> just one word: SEARCH-n (where n is the number of days). In the message
> body, place any text to search for.
> =======================3D=======================
> D=
> 


Reply via email to