SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,367 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to update the transaction colum in the table that has previous transaction(TansactionSequence minus one) from Y to E.
Ex:Update Transaction colum 5 and 10 to E
Note: 1. TansactionSequence with 1 is always Y, and can have multiple Transaction Sequence numbers.
2. SequenceNo is a primary Key
It seems that you did not give all of details. Try this statement:
update T
set Transactions = 'E'
from
(
select *, lag(Transactions) over (partition by CreditCardNumber order by TransactionSequence) as pt
from MyTable
) T
where pt = 'E'