473,480 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Splitting Positive and Negative Figures into Separate Columns

2 New Member
Hi, hoping someone can help…

I have a table called “Table1” and within it are various columns including a “Transactions” column that contain both credit and debit (positive and negative) transactions. As well as the “Transactions” column in “Table1” there is also an “Account Number” column. There are several account numbers and each account number has several transactions.

The end goal is to create a query that splits the debit/credit transactions into separate columns and then totalled for each account.

Iv tried creating one query with <0 criteria under the “Transactions” field for negative and vice versa for positive then a third to bring the two columns together but it’s not really working!

Ideally it would be great to do from one query but think it may be unlikely to do from the query ‘design view’.

Whilst I have no experience with SQL, I am confident of following any clear guidance offered.

I thank you in advance!
Feb 15 '12 #1
3 5680
Narender Sagar
189 New Member
If your table also has one of field something like "Transaction_Type", e.g. for every negative transaction "DR" and for positive transaction "CR", then you can create "Crosstab Query" and keep above field in columns & other required fields in Rows. Then I think you'll get result the way you want it.
Feb 15 '12 #2
Rabbit
12,516 Recognized Expert Moderator MVP
You can also use the IIF function to split your column without multiple queries.

But if you want to continue down the multiple queries, create a positve query and a negative query, then union them. Each will require a dummy field.
Feb 15 '12 #3
Giles Marriott
2 New Member
thanks guys, really appreciate it.

Iv cracked it with the IF staments. Created two new columns, one column:

Credits: IIf(Table1.Transactions > 0, Table1.Transaction,0)

The second column:

Debits: IIf(Table1.Transactions < 0, Table1.Transaction,0)


Thanks again.
Feb 15 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3544
by: Dig314 | last post by:
I need to Total the amounts for each Property ID in a table. All the amounts are stored as positive in the database. Based on a transaction code, the amount should be added or subtracted. There...
3
28091
by: Ken Durden | last post by:
Is it possible to force positive values to have the + sign prefixed on them? double f1 = 1024.2; double f2 = -1024.2; string.Format( "{0:F}", f1 ); // +1024.2 string.Format( "{0:F}", f2 );...
3
1960
by: vishwassap | last post by:
Hi All, Any One Pls Tell Me The Difference Between Positive & Negative Sql .
4
1853
by: mikevde | last post by:
Hi, I have a query where I select all the values from my MS SQL table that are LIKE a certain string. The query works, but in the ASP page, I only want to write the date once, while writing the...
3
1390
by: nfrjob | last post by:
Hi there, I'm stuck here and would appreciate any nudges or ideas! My basic scenario is this - I have a table with duplicate records and I need to take the values from the duplicate records and...
5
2291
by: vbgunz | last post by:
/* * BEGIN EXAMPLES */ var text = 'A Cats Catalog of Cat Catastrophes and Calamities'; /*** * EXAMPLE 1: negative lookahead assertion logic ***/
0
2171
by: HughManity | last post by:
I was sent an Excel xls file where the Address column consists of up to 3 address lines stacked on top on each other - all in one cell. If there is more than one line in a cell, then all but the...
3
2307
by: acs7737 | last post by:
i have this hw problem for class thats supposed to read a comma separated list of my cd collection ex.: artist,album artist,album artist,album it reads that into a string and then has to separate...
1
1226
by: jremio | last post by:
Hey I was wondering how do I go about doing this. strCommand = readCommand("aaa;sss;ddd", 1) MsgBox (strCommand) Public Function readCommand(str As String, position As Integer) As String...
0
7041
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7043
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6921
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5336
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4776
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2995
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.