Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / May 2005

Tip: Looking for answers? Try searching our database.

HELP!!! - Me again

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mr. Capuchino - 11 May 2005 09:05 GMT
I have two tables..
Both have field names (AccountDescription, Amount, WTAX, InputTAX, NetofVAT,
StatementCode)
The Statement Code is either a BS or P&L.
I need one query that will group similar AccountDescriptions, give me the
sum of the Amount, WTAX, InputTAX, NetofVAT for BS on both the tables and
another for P&L on both tables. Please help on how to do this...
LeAnne - 11 May 2005 16:19 GMT
Hi,

Since you have a non-normalized design (2 tables with identical
structure), I recommend first contructing a UNION query to combine the
two tables, and then basing both Totals queries on the UNION query. Post
back if you need more info.

hth,

LeAnne

> I have two tables..
> Both have field names (AccountDescription, Amount, WTAX, InputTAX, NetofVAT,
[quoted text clipped - 3 lines]
> sum of the Amount, WTAX, InputTAX, NetofVAT for BS on both the tables and
> another for P&L on both tables. Please help on how to do this...
Mr. Capuchino - 13 May 2005 02:01 GMT
Hi LeAnne
Thank for the reply
Actually the 2 tables don't have identical structure. One table has more
fields than the other. It would really be helpful if you could give me some
idea on how to make a UNION query. Thanks!

> I have two tables..
> Both have field names (AccountDescription, Amount, WTAX, InputTAX, NetofVAT,
[quoted text clipped - 3 lines]
> sum of the Amount, WTAX, InputTAX, NetofVAT for BS on both the tables and
> another for P&L on both tables. Please help on how to do this...
Mr. Capuchino - 13 May 2005 02:40 GMT
I forgot to add... that one table has more fields than the other and one
table has more rows. I have read a bit about UNION query and i think that my
tables are not union-compatible... Can anyone help me get by this problem?
Thanks!

> I have two tables..
> Both have field names (AccountDescription, Amount, WTAX, InputTAX, NetofVAT,
[quoted text clipped - 3 lines]
> sum of the Amount, WTAX, InputTAX, NetofVAT for BS on both the tables and
> another for P&L on both tables. Please help on how to do this...
Douglas J. Steele - 13 May 2005 11:44 GMT
The number of rows makes no difference for Union queries. You do need the
same number of fields in each subquery. However, you can do this by querying
only a subset of the fields in the wider table, or by padding the field list
in the narrower table:

SELECT Field1, Field2, Field3
FROM NarrowTable
UNION
SELECT Field1, Field3, Field5
FROM WiderTable

or

SELECT Field1, Field2, Field3, Field4, Field5
FROM WiderTable
UNION
SELECT Field1, " ", Field2, 0, Field3
FROM NarrowerTable

Note in the second example that field types must agree: the example assumes
Field2 in WiderTable is a text field and Field4 is numeric, so I padded with
"" and 0 respectively. You could also pad with Null (regardless of the field
type), but depending on what you're doing with the resultant recordset,
that's not always appropriate.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I forgot to add... that one table has more fields than the other and one
> table has more rows. I have read a bit about UNION query and i think that
[quoted text clipped - 10 lines]
>> sum of the Amount, WTAX, InputTAX, NetofVAT for BS on both the tables and
>> another for P&L on both tables. Please help on how to do this...
Mr. Capuchino - 15 May 2005 10:54 GMT
Thanks! i'll let you know if it works!

> The number of rows makes no difference for Union queries. You do need the
> same number of fields in each subquery. However, you can do this by querying
[quoted text clipped - 35 lines]
> >> sum of the Amount, WTAX, InputTAX, NetofVAT for BS on both the tables and
> >> another for P&L on both tables. Please help on how to do this...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.