Solved

pleas help to make a Query

Posted on 2004-10-05
3
448 Views
Last Modified: 2012-05-05
hi,
could anyone help me to make a query. My table in Microsoft Access
here's my table Structure.

TCode      Text      10
TrnNo      Number
TrnDate      Date
Amount      Number
DCFlag      Text      1

i'd like to make a query for below mentioned result. In this result, if the DCFlag='C' the amount should come under 'Credit' and the DCFlag='D' the amount should come under 'Debit'.

TCode      TrnNo       TrnDate                Debit            Credit
------------------------------------------------------------------------
ABC      001      10/02/2003             100    
ABC      005           12/02/2003                        75
XYZ      002      11/02/2003            1570    
XYZ      003      12/02/2003                     1570

in advance, thanks so much for ur great help.
0
Comment
Question by:satdream
  • 2
3 Comments
 
LVL 1

Expert Comment

by:Wigz
ID: 12224936
select TCode, TrnNo, TrnDate, iif(DCFlag= 'D', Amount, 0) as Debit, iif(DCFlag, 'C', Amount, 0) as Credit
order by TCode, TrnNo

This will return numeric values in the Debit and Credit columns. You could replace the 0 with null if you want it to show spaces eg iif(DCFlag='D', Amount, null) as Debit.

0
 
LVL 1

Accepted Solution

by:
Wigz earned 50 total points
ID: 12224946
whoops - left out the table. That should be

select TCode, TrnNo, TrnDate, iif(DCFlag= 'D', Amount, 0) as Debit, iif(DCFlag, 'C', Amount, 0) as Credit
from tablename
order by TCode, TrnNo
0
 

Author Comment

by:satdream
ID: 12225162
dear friend
Thankx so much for ur kind help....... i had only 50 points. that's hwy i gave 50 points. u deserve more than that....
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
database design 10 93
microsoft access question 8 46
How to know which tables getting lock escalation 4 36
report returning null 21 52
Read about achieving the basic levels of HRIS security in the workplace.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now