Minggu, 22 April 2012

RE: [MS_AccessPros] Record(n) - Record(n-1)

 

Hendra-

Try this:

SELECT T1.[Value], (T1.[Value] - NZ(T2.[Value], 0) As Result
FROM MyTable As T1,
(SELECT 0 As [Value] FROM MyTable
UNION SELECT [Value] FROM MyTable) As T2
WHERE T2.[Value] =
(SELECT Max([Value]) FROM T2
WHERE T2.[Value] < T1.[Value]);

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

----------------------------------------------

From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of
agesthahendra@ymail.com
Sent: Sunday, April 22, 2012 9:49 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Record(n) - Record(n-1)

 
Hi everyone...

Let say we have a field named Value,
how can we calculate in query for the result to (Record(n))-(Record(n-1)),
maybe it more simple to understand if i give an example like below :

Value Result
1 1
5 4
8 3
10 2

Results : (1)=1-(no record (n-1)), (4)=5-1, (3)=8-5, (2)=10-8 ...

Any explanation would be very appreciated...thenk you very much

Regards
Hendra

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar