473,394 Members | 1,956 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,394 software developers and data experts.

Combining Records From Two Different Tables

Here I need a help. I have two tables 1) Mis_A 2) Mis_B

Mis_A Mis_B
Location Revenue Location Sale
Mumbai 10 Mumbai 5
Mumbai 10 Chennai 10
Goa 5 Madras 10
Goa 5 Goa 5
I need an output in the Format shown below with sql query
Location Total(Revnue+Sale)
Mumbai 25
Goa 15
Chennai 10
Madras 10
Thanks in advance

Dec 9 '06 #1
2 1483
1. Create a new query, and type this into SQL View:
SELECT Location, Revenue FROM Mis_A
UNION ALL
SELECT Location, Revenue FROM Mis_B;
Save. Close.

2. Create another query using the first one as your input "table."
Depress the Total button on the toolbar.
Access adds a Total row to the grid.
You can now Group By the Location, and Sum the Revenue.

If practical, the best solution would be to combine the data from Mis_A and
Mis_B into one table, probably with an extra field to indicate whatever the
difference is.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nitin" <ni********@gmail.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
Here I need a help. I have two tables 1) Mis_A 2) Mis_B

Mis_A Mis_B
Location Revenue Location Sale
Mumbai 10 Mumbai 5
Mumbai 10 Chennai 10
Goa 5 Madras 10
Goa 5 Goa 5
I need an output in the Format shown below with sql query
Location Total(Revnue+Sale)
Mumbai 25
Goa 15
Chennai 10
Madras 10

Thanks in advance

Dec 9 '06 #2

Allen Browne wrote:
1. Create a new query, and type this into SQL View:
SELECT Location, Revenue FROM Mis_A
UNION ALL
SELECT Location, Revenue FROM Mis_B;
Save. Close.

2. Create another query using the first one as your input "table."
Depress the Total button on the toolbar.
Access adds a Total row to the grid.
You can now Group By the Location, and Sum the Revenue.

If practical, the best solution would be to combine the data from Mis_A and
Mis_B into one table, probably with an extra field to indicate whatever the
difference is.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nitin" <ni********@gmail.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
Here I need a help. I have two tables 1) Mis_A 2) Mis_B

Mis_A Mis_B
Location Revenue Location Sale
Mumbai 10 Mumbai 5
Mumbai 10 Chennai 10
Goa 5 Madras 10
Goa 5 Goa 5
I need an output in the Format shown below with sql query
Location Total(Revnue+Sale)
Mumbai 25
Goa 15
Chennai 10
Madras 10

Thanks in advance
Thanks Allen
I implemented your logic, I used 1st option it is working fine.

Dec 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kenneth Fosse | last post by:
Hi. I'm currently working on a project which involves the creation of a web page which reports selected data to customers from two back-end systems. I use ASP script language on IIS, the server...
8
by: Ilan | last post by:
Hi all I need to add data from two Excel sheets (both on the same workbook) to an existing table in my SQL DB. The problem is that each sheet holds different fields for the same record, though...
22
by: Martin C | last post by:
I have inherited a database which has a table for each of our 1200 customers. Each table is exactly the same. It is very difficult to generate reports I would like to create a new table and take...
4
by: Tony Williams | last post by:
I want to combine two tables into one. I have a table with all the field definitions from two other tables. I now need to update this new table with the data from the other two tables.However both...
7
by: Frank | last post by:
Hi there, I'm trying to generate a report for an old database and I'm having trouble coming up with an elegant way of going about it. Using cursors and other 'ugly' tools I could get the job done...
1
by: ferraro.joseph | last post by:
Hi, I'm querying Salesforce.com via their AJAX toolkit and outputting query results into a table. Currently, their toolkit does not possess the ability to do table joins via their structured...
6
by: robertmeyer1 | last post by:
Hi, There are several databases that have the same tables, with different reocrds. I need to be able to combine them all into 1 in an easy manner/best. How can I do this and are there potential...
3
by: masonic35and7 | last post by:
I work for a school district, and I have just imported 6 Excel worksheets into Access 2007. Now I have 6 different tables. In each table all the fields are the same. I need the easiest way to...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
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: 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?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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.