Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

QUERY TO ASSIGN TRANSACTION AMOUNT TO DEBIT OR CREDIT

Posted on 2011-03-10
2
Medium Priority
?
600 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 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

610 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