TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
hemant kolekar
NA
15
3.5k
How to Subtract in case Statment in self Table
Dec 10 2015 6:51 AM
SELECT Payment_Id, Pay_Booking_Id, Convert(varchar(50),Payment_Date,103)AS Payment_Date,Narration,Amount,
CASE WHEN Transaction_Type = 'M' THEN 'Mile Stone' ELSE CASE WHEN Transaction_Type = 'R' THEN 'Reciept' ELSE CASE WHEN Transaction_Type = 'P' THEN 'Payment' ELSE CASE WHEN Transaction_Type = 'DT' THEN 'Direct Transfer' ELSE CASE WHEN Transaction_Type = 'C' THEN 'Journel Credit' ELSE 'Journel Debit' END END END END END as Transaction_Type ,
CASE WHEN Transaction_Type = 'M' THEN
ISNULL((SELECT SUM(Adj_Amount) FROM Adjustment WHERE Adj_What_Id = Payment_Id ), 0.000)
ELSE
ISNULL((SELECT SUM(Adj_Amount) FROM Adjustment WHERE Adj_Payment_Id = Payment_Id AND Adj_What_Id = Payment_Id),0.000)
END AS Adj_Amount_OtherTxn,
0.000 AS Adj_Amount_thisTxn
FROM Payment Pay WHERE Pay_Booking_Id = @Booking_Id
Given Below Image Where Payment _Id 496 Which Transaction type in PAyment it is amount Subtract in Payment _Id 240 Which Transaction type AGREEMENT
Like Agreement Amt = 521807.000
Payment Amt = 4000.000
Which minus Amount shoulde be 517807.000
Reply
Answers (
1
)
SQL Stored Proceudrer Datetime
Sql Server View to Generic List