Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

pleas help to make a Query

Posted on 2004-10-05
3
Medium Priority
?
480 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
[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
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 200 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

670 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