Difference in Numbers

ashishkukreja

Registered User.
Local time
Today, 13:06
Joined
Jul 27, 2007
Messages
19
How can we calculate a difference of column

Example

when I have a table containing a single row i.e.

Numbers
66
45
23
52
523
563
452
133

Now I required a query that must show a difference like this

Numbers ------------------ Difference
66 ------------------------ 0
45 ------------------------ -21----------- (45-66)
23 ------------------------ -22 ------------(23-45)
52 ------------------------ +29 ------------ (52-23)
523 ------------------------ +471----------- (523-52)
563 ------------------------ +40 ------------ (563-523)
452 ------------------------ -111 ----------- (452-563)
133 ------------------------ -319 ------------(133-452)

So it is possible or not
Please tell me
Waiting for reply

Thanks
Ashish
 
Last edited:
You can add a numeric ID field to your table, number the records as 1,2,3,.. to 8 in the ID field and run this query:-

SELECT a.Numbers, Nz(a.Numbers- b.Numbers)+0 AS Difference
FROM [TableName] AS a LEFT JOIN [TableName] AS b ON a.ID-1 = b.ID;


when I have a table containing a single row (column?) i.e.

Numbers
66
45
23
52
523
563
452
133
Just curious ... but why do you have a table with such a structure? What's it for?
.
 
Thanks for reply sir
I have a lot of columns in my table but I want to put a formula in single row
I just try and reply you about this formula it is working for me or not

Thanks again for your reply
Ashish
 

Users who are viewing this thread

Back
Top Bottom