To Add % In Query

Z

zyus

I hv this sql in my query. How to add in % for my net_bal by brncd. TQ

SELECT [Tbl-SKS].BRNCD, Count([Tbl-SKS].ACNO) AS CountOfACNO,
Sum([Tbl-SKS].NET_BAL) AS SumOfNET_BAL
FROM [Tbl-SKS]
GROUP BY [Tbl-SKS].BRNCD, [Tbl-SKS].ARRMTH
HAVING ((([Tbl-SKS].ARRMTH)=5))
ORDER BY Sum([Tbl-SKS].NET_BAL) DESC;
 
M

Maarkr

if you're asking how to format it to display percent, you should set the
form/report field format to "Percent".
 
J

John W. Vinson

How to add in % for my net_bal by brncd.

Zyus, you're assuming more knowledge of your cryptic fieldnames and
application than any of us could possbily have.

Explain please?
 
Z

zyus

Sorry guys. I thought i hv given a clear exp.

When i run my query i hv this as result. I want to get number & sum amount
group by branch (brncd) who's having account = to 5 mth in arrears. What i
want to add is the % column for SumOfNetbal as per sample below

BRNCD CountOfACNO SumOfNetBal %
00001 5 100 10
00002 3 300 30
00003 10 600 60

I hope my exp is clear
 
J

John W. Vinson

Sorry guys. I thought i hv given a clear exp.

Zyus, please step back a bit. Clear your mind of your knowledge of your
application. Read your post with the assumption that what's posted to the
newsgroup is *all of the information that you have*. That's our situation.
When i run my query i hv this as result. I want to get number

"get number". What number?
& sum amount

"sum amount". What amount?
group by branch (brncd)

ok, that's clear...
who's having account = to 5 mth in arrears.

How does Access identify which account is 5 months in arrears?
What i
want to add is the % column for SumOfNetbal as per sample below

GUESSING here you want the percent field (which should certainly not be named
%) should be this row's value of SumOfNetBal divided by the grand total of
SumOfNetBal... right? If so try a calculated field

SumOfNetBal / Sum(SumOfNetBal)

and format the field as Percent.
 
Z

zyus

John,

Number - Count number of account for each branch
Sum Amount - Sum nett balance amount for each branch

I've added the sql based on your suggestion but i've got error msg
"subqueries cannot be used in the expression (sum(sumofNet_bal))
 
Z

zyus

Sorry this is my sql

SELECT [Tbl-SKS].BRNCD, Count([Tbl-SKS].ACNO) AS CountOfACNO,
Sum([Tbl-SKS].NET_BAL) AS SumOfNET_BAL, SumOfNET_BAL/Sum(SumOfNET_BAL) AS
PercentOfNET_BAL
FROM [Tbl-SKS]
GROUP BY [Tbl-SKS].BRNCD, [Tbl-SKS].ARRMTH
HAVING ((([Tbl-SKS].ARRMTH)=5))
ORDER BY Sum([Tbl-SKS].NET_BAL) DESC;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top