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!
3 5697
If your table also has one of field something like "Transaction_Ty pe", 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.
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.
thanks guys, really appreciate it.
Iv cracked it with the IF staments. Created two new columns, one column:
Credits: IIf(Table1.Tran sactions > 0, Table1.Transact ion,0)
The second column:
Debits: IIf(Table1.Tran sactions < 0, Table1.Transact ion,0)
Thanks again.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 are about 14 transaction codes, but here is an example:
Transaction Code "Addition" - - add the amount
Transaction Code "Disposal" - - subtract the amount
Can this be done in single select statement ?
|
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 ); // -1024.2
I was hoping for something either in the string.Format prefix, or
|
by: vishwassap |
last post by:
Hi All,
Any One Pls Tell Me The Difference Between Positive & Negative Sql .
|
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 values from the other column in all cases.
To illustrate, i have a table that looks like this:
ID Date Name
1 2007/01/01 city_house
2 2007/01/02 city_farm
3 2007/01/02 city_house
|
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 place them into separate columns. The table structure is similar to this (sorry - periods are being used as separators):
SAMPLE....VALUE
G1234...........50
G1234...........68
What I'm aiming for is something like this (preferably stored in a...
| |
by: vbgunz |
last post by:
/*
* BEGIN EXAMPLES
*/
var text = 'A Cats Catalog of Cat Catastrophes and Calamities';
/***
* EXAMPLE 1: negative lookahead assertion logic
***/
|
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 last line will have a square-cylinder looking character to the right of it. If you right-click the cell and select Format Cells, the Sample box has the lines separated by two square characters. If you click the Alignment tab and, in Text Control,...
|
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 the artists into one vector and the album into another and then place the artist vector in one column and the album vector into another column
i think i can do the column part but i have no clue how to separate the whole thing into two vectors....
|
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
If position = 1 Then
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 we have to send another system
| |