tsql - Date Range between the Last 2 Records Sql Server 2008 -
Hi, Seeing that I have a table with 2 columns.
The table bookings column - TransactionDate
I get the total amount between the previous 2 transactions.
How do you do this? How do you get the last transaction but 01 any suggestions?
You assign a serial number of each row based on the descending order of the transaction date Can use normal table expression (CTE). And then select the rows with a filter to get the last 2 rows.
This query displays the last two transactions in the table
with the BookingCTE AS (SELECT ROW_NUMBER () sequence (amount, the form of booking from the transaction) In the form of the order (transaction date DEC) from order, select the booking, the ticket, the booking of ticket from CTE and Lt; = 2;
This query will give you the last two lanes - The total amount of the donation is received.
Booking as CT (Selection Number ROW_NUMBER) (Ord Off Anjakshn sequence where debt Diissi) as sequence, amount, select the transaction date) the booking amount booking of total assets as of (amount) & lt; = 2;
Comments
Post a Comment