sql - Access VBA: Get difference in value between current and previous record -


I created a report based on this link based on queries:

It gives me the list of records with values:

(primary) · ID ....... for the first time .... semender ..... diameter .. ... owner
1 ........ 100200 ....... 01 ............... 150 ......... ..... peter 2 ........ 100200 ....... 02 ............... 138 ....... ...... .Peter # 3 ........ 100300 ....... 07 ............... 112 ..... ...... ... John

In the descending order by the diemetral, I create a new column of the query type. I know that the difference between the first and the second records is counted, then between the third and the second and so on. In this way:

(primary)
ID ....... First news .... sandydam ..... diameter ..... defhidametral ..... owner
1 ........ 100200 ....... 01 ............... 150 ............. ..... ........................ Peter
2 ........ 100200 ....... 02 ................... 138 ................. ................... ... Peter
3 ........ 100300 ....... 07 ............... 112 ......... .... 26 ..................... John

To get these values, I use RowSource for DiffDiametral or What do I write in DataSource? How can I avoid error for the first line, where is not the last value that I want?

I tried to solve it according to this link: but I did not solve it. Just do not know how I can reference the difference of the diameter to calculate the difference.

Depending on your information, a subquery should do this. Just replace your actual table name for tblDiameters. Select

  C.ID, C.FirstNum, C.SecNum, C.Diameter, C.Owner, (SELECT TOP 1 P. Diameter FROM TblDiameters AS P WHERE P. Diameter & lt ; C.Diameter ORDER BY P.Diameter DESC) - c. DIF as DIDF by DIDF as TblDiameters C    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -