A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Crosstab qry not adding up



 
 
Thread Tools Display Modes
  #1  
Old November 20th, 2009, 02:19 AM posted to microsoft.public.access.queries
deb
external usenet poster
 
Posts: 898
Default Crosstab qry not adding up

I've built a crosstab qry for a tenant sales database based on a select qry,
the original select query works (adds up correctly) ive checked by sorting
and adding totals to columns, but the crosstab is tripling the amounts in
each total field both for each month and the totals - i'm thinking its
something to do with the fact there are three different income types (rent,
cleaning, other) because the rows where the tenant has only one income type
are correct

this is the code

TRANSFORM Sum(SalesToTenant.[Amount]) AS SumOfAmount
SELECT SalesToTenant.[Company], SalesToTenant.[IncomeType],
Sum(SalesToTenant.[Amount]) AS [Total Of Amount]
FROM SalesToTenant
GROUP BY SalesToTenant.[Company], SalesToTenant.[IncomeType]
PIVOT Format([Date],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");
--
deb
  #2  
Old November 20th, 2009, 06:43 AM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Crosstab qry not adding up

You did not post the the original select query SQL. That might be the
problem when it feeds the crosstab.

--
Build a little, test a little.


"deb" wrote:

I've built a crosstab qry for a tenant sales database based on a select qry,
the original select query works (adds up correctly) ive checked by sorting
and adding totals to columns, but the crosstab is tripling the amounts in
each total field both for each month and the totals - i'm thinking its
something to do with the fact there are three different income types (rent,
cleaning, other) because the rows where the tenant has only one income type
are correct

this is the code

TRANSFORM Sum(SalesToTenant.[Amount]) AS SumOfAmount
SELECT SalesToTenant.[Company], SalesToTenant.[IncomeType],
Sum(SalesToTenant.[Amount]) AS [Total Of Amount]
FROM SalesToTenant
GROUP BY SalesToTenant.[Company], SalesToTenant.[IncomeType]
PIVOT Format([Date],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");
--
deb

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.