Solved

QUERY TO ASSIGN TRANSACTION AMOUNT TO DEBIT OR CREDIT

Posted on 2011-03-10
2
586 Views
Last Modified: 2012-05-11
Hi All,

I have transaction which are :

1. Money Receive.
2. Money Pay.

Query Condition :

1. When Receive then Debet.
2. When Receive and Minus Then Credit

3. When Pay then Credit.
4. When Pay and Minus Then Debit

Below are my code :

CASE WHEN RIGHT(A.TipeTransaksi, 1) = 'D' THEN B.TransactionAmount ELSE 0.00 END AS Debit"
CASE WHEN RIGHT(A.TipeTransaksi, 1) = 'C' THEN B.TransactionAmount ELSE 0.00 END AS Credit"

How to add condition for minus TransactionAmount  to the right place, Debit or Credit?

Thank you.


0
Comment
Question by:emi_sastra
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
Ryan McCauley earned 500 total points
ID: 35106098
It's a little long, but this would work:


CASE WHEN RIGHT(A.TipeTransaksi, 1) = 'D' AND B.TransactionAmount > 0 THEN B.TransactionAmount
     WHEN RIGHT(A.TipeTransaksi, 1) = 'C' AND B.TransactionAmount < 0 THEN -1 * B.TransactionAmount
     ELSE 0.00
END AS Debit,
CASE WHEN RIGHT(A.TipeTransaksi, 1) = 'C' AND B.TransactionAmount > 0 THEN B.TransactionAmount
     WHEN RIGHT(A.TipeTransaksi, 1) = 'D' AND B.TransactionAmount < 0 THEN -1* B.TransactionAmount
     ELSE 0.00
END AS Credit

Open in new window

0
 
LVL 1

Author Comment

by:emi_sastra
ID: 35106634
Hi ryanmccauley,

It works.

Thank you very much for your help.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question