Hi,
I am trying to write an Aged Debtors report in MSquery, I have created
all of the columns sucessfully, I just need to have totals of each
column at the bottom of the report - how can this be done?
this id the code that I have so far: -
select
cucode,
cuname,
cuphone,
cubalance,
sum(case when st_date between (getdate()-30) and Getdate() then
st_gross end )as '0-30days',
sum( case when st_date between (getdate()-60) and (Getdate()-30) then
st_gross end) as '30-60days',
sum( case when st_date between (getdate()-90) and (Getdate()-60) then
st_gross end )as '60-90days',
sum( case when st_date between (getdate()-120) and (Getdate()-90) then
st_gross end )as '90-120days',
sum( case when st_date between (getdate()-180) and (Getdate()-120) then
st_gross end )as '120-180days',
sum( case when st_date > (getdate()-180) then st_gross end) as
'180days +'
from sl_accounts, sl_transactions
where
cucode = st_copycust
and cubalance <> 0
group by cucode, cuname, cuphone, cubalance
order by cucode 2 4832
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Standard SQL doesn't provide a column total function. Use the data from
the query in a reporting application like Crystal Reports, Access or
Excel. They have provisions for column totaling functions.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQlrRmIechKqOuFEgEQLOhQCg46aS2zVSNhEAfG5HgPeV2K kN4z0AnjsB
sUbC6lWuSpi3X84Un4K6mGTV
=H11y
-----END PGP SIGNATURE-----
Darren wrote: Hi,
I am trying to write an Aged Debtors report in MSquery, I have created all of the columns sucessfully, I just need to have totals of each column at the bottom of the report - how can this be done?
this id the code that I have so far: -
select cucode, cuname, cuphone, cubalance,
sum(case when st_date between (getdate()-30) and Getdate() then st_gross end )as '0-30days', sum( case when st_date between (getdate()-60) and (Getdate()-30) then st_gross end) as '30-60days', sum( case when st_date between (getdate()-90) and (Getdate()-60) then st_gross end )as '60-90days', sum( case when st_date between (getdate()-120) and (Getdate()-90) then st_gross end )as '90-120days', sum( case when st_date between (getdate()-180) and (Getdate()-120) then st_gross end )as '120-180days', sum( case when st_date > (getdate()-180) then st_gross end) as '180days +' from sl_accounts, sl_transactions
where cucode = st_copycust and cubalance <> 0
group by cucode, cuname, cuphone, cubalance order by cucode
Darren,
Access on its own won't do what you want in just a query. SQL Server,
though, through TransactSQL, can build a temporary table with the totals as
the last row in the table. First use an insert statement to add all the
rows to your temporary table from the result set. Then run a seperate
insert statement to insert the last row with the totals. JetSQL doesn't
support scripted SQL--multiple SQL statements in the same query object
(dang)--so if you do want to implement this in Access VBA combined with SQL
is the best choice (macros--yuck).
--
Alan Webb kn*******@SPAMhotmail.com
"It's not IT, it's IS"
"Darren" <da*******@ntlworld.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... Hi,
I am trying to write an Aged Debtors report in MSquery, I have created all of the columns sucessfully, I just need to have totals of each column at the bottom of the report - how can this be done?
this id the code that I have so far: -
select cucode, cuname, cuphone, cubalance,
sum(case when st_date between (getdate()-30) and Getdate() then st_gross end )as '0-30days', sum( case when st_date between (getdate()-60) and (Getdate()-30) then st_gross end) as '30-60days', sum( case when st_date between (getdate()-90) and (Getdate()-60) then st_gross end )as '60-90days', sum( case when st_date between (getdate()-120) and (Getdate()-90) then st_gross end )as '90-120days', sum( case when st_date between (getdate()-180) and (Getdate()-120) then st_gross end )as '120-180days', sum( case when st_date > (getdate()-180) then st_gross end) as '180days +' from sl_accounts, sl_transactions
where cucode = st_copycust and cubalance <> 0
group by cucode, cuname, cuphone, cubalance order by cucode This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: CSDunn |
last post by:
Hello,
I have 14 fields on a report that hold integer values. The field names
use the following naming convention: T1Number, T2Number ....T14Number.
I need to get a 'sub total' of all fields as...
|
by: Coleen |
last post by:
Hi All :-)
Cor & David, Thank you for your help, sorry I did not reply before now, but
for some reason my Newsgroup Reader (Outlook) does not show your last posts.
The last one I got from Cor...
|
by: Coleen |
last post by:
Hi All :-)
Thanks for all of your help Cor :-)
I can not get the code you sent me to work in my application. I'm using an aspx datagrid in a web form. I'm getting the following error message...
|
by: baseballswim123 |
last post by:
Friend,
I'm always looking for good and intelligent individuals like you to
visit my website, www.ChezBrandon.com , and it has pictures of
beautiful women, information about aged clones, and a...
|
by: jessicaeatworld |
last post by:
Hi,
I'm using Access 2003 on Windows XP. I have created a PivotTable View Form and at the bottom is an automatically inserted Grand Total row. I added sum and avg fields and then hid the details so...
|
by: smacky61 |
last post by:
How do I summarize a report by finding the totals fees collected for each event and the grand total of all fees. The name of the report is Registered Attendees Report.
|
by: Micheal |
last post by:
Greetings Access Group,
Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
|
by: peter1234 |
last post by:
I am trying to produce study notes for ACCESS, and for many days I am stuck trying to produce totals and subtotals for table ‘Order Details’ from ‘Northwind Sample Access Database’. The fact that I...
|
by: Bytesmiths |
last post by:
I'm using GROUP BY to come up with totals for some items, but would like to either have a grand total at the bottom, or a running total field.
I tried to use a variable as I found in several...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
|
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,...
| |