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

Combine four table fields into one record

I've been racking my brains all day over this. And I'm not the best
at SQL either.

I need a query that will produce the following results:
Product,Warehouse,Sold_LastYear,Sold_ThisYear,Sold _3Months,Sold_MTD

I've got four queries to give me the Sold_* fields. Their fields are
Product, Warehouse, and Units. I also have a table which these
queries originated from. The table UV_SPPROD (I didn't name it) has
Product, Warehouse, Period (aka date), and Units. Basically, the four
queries remove the date and give me the unit sum for a given date
range. Those queries all work fine.

My trouble is that when trying to pull in all the data, I can't seem
to match the product and warehouses for the four queries together to
get me a combined output. Just to make things more difficult, not all
periods are listed for each product/warehouse combination meaning that
I cannot simply join all product fields and all warehouse fields
together. I may "lose" data. At least that's what my tests showed.

I've tried using the base table UV_SPPROD to perform a left join but
seem to get cartesian joins with the data or lost data. I've also
tried a union with zeros as placeholders. That will work if I create
a final query to sum based on product and warehouse. I'm hoping to
create one query that will write the information.

Any help is appreciated.

-Chris
Nov 12 '05 #1
1 1726
I feel you are close. Left joins are what I would use in this case,
anyway. The "source table" (on that left side) should include all
possible combinations, maybe that requires an extra query.

The query should have five source objects, all of them probably queries
themselves. Four are joined "with arrow". Right?

You have arrived correctly at the observation that you cannot use simple
joins. Maybe there is a workaround in a crosstab query (produce a result
set that calculates your columns and adds a label, then do the crosstab
-- nah, forget it, way too difficult)

If you need that extra last query, do it. Have a result first, trouble
yourself for speedups later.

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #2

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

Similar topics

8
by: mark | last post by:
Access2000 How do I write a query that combines the CTC field from each record below into one record? I need to concatenate the CTC field with a separator, like below: ...
1
by: snOOp | last post by:
I am trying to combine the data from two similar tables into one query, but I need for all of the records from both tables to show up and I want the ones that have matching 'emplid' to be combined...
5
by: Jamie Pittman via AccessMonster.com | last post by:
I have two tables with 5000 entries on them. One is based for regular time with several variables example (employee name, date,time in and out, code, customer, building) I have another table that...
1
by: rdraider | last post by:
Hi all, We have an app that uses SQL 2000. I am trying to track when a code field (selcode) is changed on an order which then causes a status field (status) to change. I tried a trigger but...
4
by: Jason Gyetko | last post by:
Is there any way to combine these two queries into one? I have tables Item_Master & Kit_Master which are the source tables. Query 2 is using both Item_Master (table) & qryKit1 (query) &...
7
by: carlos139 | last post by:
I have a access table that contains multiple reccords per client. I want to combine each record based on the client into one row with separate field names. Table below: JobNbr, LineNbr,...
1
by: bluereign | last post by:
Thank you for your assistance. I am a novice looking to JOIN and append or combine records from 2 current Tables into 2 new Tables named below. I have been able to JOIN Tables with the script...
3
by: klbachrodt | last post by:
Hi all - I've been browsing this forum for a while now, looking for help, and finally decided to join and ask my question, since I'm not terribly good at writing SQL queries in Access. Here is my...
2
by: mzmatterafact | last post by:
I'm back and please be warned I'm a total NEWBIE, and i've had success with my previous post so I would like to buy another vowel! Now i have taken my csv file and imported to a DataTable, i've...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.