473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Three year similar value access query

Hello guys
I have a database with three tables each containing the following fields, AccountNo, CustomerName, Table2003,Table2004, Table2005. I would like to make a query that will produce the accountnumber, and customername for all customers with the similar balance in table2003,table2004, and table2005. Right now my query gives me the results for just about every customer with balances in all three years but i specifically want to see the ones with the same amount being carried forward for all three years. Any ideas as to how I may go about doing this would be greatly appreciated.
Mar 4 '07 #1
7 1521
nico5038
3,080 Expert 2GB
Hello guys
I have a database with three tables each containing the following fields, AccountNo, CustomerName, Table2003,Table2004, Table2005. I would like to make a query that will produce the accountnumber, and customername for all customers with the similar balance in table2003,table2004, and table2005. Right now my query gives me the results for just about every customer with balances in all three years but i specifically want to see the ones with the same amount being carried forward for all three years. Any ideas as to how I may go about doing this would be greatly appreciated.
Basically you're design isn't normalized and you should have one table with an additional "YEAR" field.

Now first create a UNION query like:
select "2003" as Year, * from Table2003
UNION
select "2004" as Year, * from Table2004
UNION
select "2005" as Year, * from Table2005;

To get all data in one and use that query for collecting the customerdata.

Clear or do you need more info ?

Nic;o)
Mar 4 '07 #2
Basically you're design isn't normalized and you should have one table with an additional "YEAR" field.

Now first create a UNION query like:
select "2003" as Year, * from Table2003
UNION
select "2004" as Year, * from Table2004
UNION
select "2005" as Year, * from Table2005;

To get all data in one and use that query for collecting the customerdata.

Clear or do you need more info ?

Nic;o)
hmm, i am trying to digest this Nico. Could you please give me some more info? I at first had all the data in one table but I separated them into three different tables according to year, so now i have three tables.
Mar 4 '07 #3
nico5038
3,080 Expert 2GB
OK, just create the UNION or use your old table.

Next place Customer, Accountnumber, Year and Balance in a query based on that.

Next change the query type to crosstable query and in the extra line with combo's from the graphical query editor use:
Customer and Accountnumber as Rowheader
Year as Columnheader
Balance as Value
Finally change the GroupBy under the Balance into Sum

When running this query you get:
Expand|Select|Wrap|Line Numbers
  1. Customer  Accountnumber  2003 2004 2005
  2. CustA       123456      12   22     33
  3. CustB       654321       2   5    133
  4. etc.
  5.  
This can be used to compare the balances of the different years.

Nic;o)
Mar 4 '07 #4
OK, just create the UNION or use your old table.

Next place Customer, Accountnumber, Year and Balance in a query based on that.

Next change the query type to crosstable query and in the extra line with combo's from the graphical query editor use:
Customer and Accountnumber as Rowheader
Year as Columnheader
Balance as Value
Finally change the GroupBy under the Balance into Sum

When running this query you get:
Expand|Select|Wrap|Line Numbers
  1. Customer  Accountnumber  2003 2004 2005
  2. CustA       123456      12   22     33
  3. CustB       654321       2   5    133
  4. etc.
  5.  
This can be used to compare the balances of the different years.

Nic;o)
Thanks Nico. I already have that query sorted out to display the results for all three years. However, what I am having difficulties with is to now have only customers with similar balances for all three years displayed instead of every single customer. That is, if customer a has $200 as a balance in all three years, I want to see him displayed in my query. Anyfurther ideas?
Mar 4 '07 #5
Thanks Nico. I already have that query sorted out to display the results for all three years. However, what I am having difficulties with is to now have only customers with similar balances for all three years displayed instead of every single customer. That is, if customer a has $200 as a balance in all three years, I want to see him displayed in my query. Anyfurther ideas?
Ok Nico and all you other guys you would never believe what worked. I typed in the criteria field for year 2003 "Is Not Null And [Table_2004.Balance]" and then in the criteria field for 2004 "Is Not Null And [Table_2005.Balance]" and voila! I got the results. Thank you again. I really appreciated the suggestions.
Mar 5 '07 #6
nico5038
3,080 Expert 2GB
Well done, you're learning fast :-)

Success with your application !

Nic;o)
Mar 5 '07 #7
NeoPa
32,556 Expert Mod 16PB
Ok Nico and all you other guys you would never believe what worked. I typed in the criteria field for year 2003 "Is Not Null And [Table_2004.Balance]" and then in the criteria field for 2004 "Is Not Null And [Table_2005.Balance]" and voila! I got the results. Thank you again. I really appreciated the suggestions.
You have the perfect answer there (Who says we wouldn't believe that worked). Don't overlook Nico's point about the data normalisation though, it can actually produce faster results which are easier to work with.
Mar 5 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Wayne B. Stanley | last post by:
I have a database with records dating back to the year 2001 I want to know how many of each Assembly was tested per year I have fields : TestDate AssemblyNo I am new to access but was able to...
6
by: Jean | last post by:
Hi, I am using an Access 2000 front-end to an Oracle 9 backend. I want to write a query that returns all records that are not older than one year for Column "Status_30" (which is a Date). ...
22
by: Kd | last post by:
I have the following set up to give me aresponse number R05-001 I would like it to reset to R06-001 at new year ResponseNo: "R" & Right(Format(Date(),"yyyy"),2) & "-" & Format(,"000") This is...
6
by: John | last post by:
Hi I have three tables with a common id with which they can be linked. I need to merge them in a way that the resultant table has all records from three tables. Below is what sort of result I am...
11
by: cansnowboard | last post by:
I built a file management database which generates a file number based on the year. i.e. 2006-PRRS-13 The criteria was that each file should be unique. So I took the primary key, added one to...
1
by: Jimmy | last post by:
I'm trying to run a query that will show only records where the year in a date field equals the current year: SELECT tblSideJob.SideJobID, tblSideJob.Date FROM tblSideJob WHERE...
2
by: Stephenoja | last post by:
Hello Guys, I have a problem that has to do with Aging Accounts Receivable. I have three tables with customer account numbers, customer names, customer balances for the years 2003, 2004 and...
8
by: Ryan | last post by:
I have a SQL view that shows data by Category and Year - so the data may look something like this. Category - Year - Amount Fruit - 2006 - $12,000 Fruit - 2007 - $16,000 Vegetables - 2006 -...
6
craigfr
by: craigfr | last post by:
I am making a graph comparing last year's defect data with YTD defect data. Our fiscal year starts Nov.1 and ends Oct.31. To get the YTD, I started used a simple date serial criteria: Between...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.