Hi Every1
Having a slight issue on creating a query to combine 2 queries, this year and last years data.
The thing is, I have data for this year for all stores, however on last year I dont for every record.
On the "combined" query, it only returns records with both this year and last year data. It "drops" any records without last years data.
Is there any way I can make the query return " " rather than null so all records are pulled through??
Many Thanks
Dan
3 1277
Hi Every1
Having a slight issue on creating a query to combine 2 queries, this year and last years data.
The thing is, I have data for this year for all stores, however on last year I dont for every record.
On the "combined" query, it only returns records with both this year and last year data. It "drops" any records without last years data.
Is there any way I can make the query return " " rather than null so all records are pulled through??
Many Thanks
Dan
Hi Dan,
Generally this is done as a union query. If your field count matches in both tables, you can do something like so -
Select * from table1
-
Union All
-
Select * from table2;
-
This should stack your results from both tables into one recordset vs trying to join them
Let us know if this is or is not the way you wish to go...and we'll provide more assistance.
J
Hi There
I have just tried the union query you suggested. Unfortunately this puts the data from the last year query into a different row.
I would like to have the data for this year and last in the same row, that way I can analyse the % change etc.
Is this possible?
Many Thanks
Dan
Its ok, I have managed to resolve this!
I have now created a relationship on store number in the query itself, showing all field for this year, and only those where last year are equal.
Thanks for your help
Dan
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 into
one record showing both the 'empstatus' and 'strole' fields.
The following query works, but does not combine the matching records:
SELECT givenname, sn, empstatus, emplid, ssn FROM dbo_EmpData
WHERE empstatus='A'
UNION ALL SELECT...
|
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 works with overtime but has
the same feilds within the table. I want to be able to run a report that
combines the regular time and overtime for the warehouse and seperated by
each customer. I have tried join tables but I keep ending with, (if it...
|
by: mojo |
last post by:
We have set up an Access database with tables x,y, & z where we would
like to have multiple people entering data into a table x. Each person
has an identical copy of the database on their PC's. When the person
is done entering the data into table x, we want them to e-mail their
database to one person who will combine the data from table x into a
single database.
What's the easiest method to combine the tables into a single table?
...
|
by: MostlyH2O |
last post by:
Hi Folks,
I have a complex query that references a sub-query. It works fine when I
call a sub-query from the main query (using design vew), but when I try to
embed the SQL text of the sub-query into the main query I get a syntax
error...
Here's the main Query. It works fine. It references another query from the
database called "Query1a"
|
by: jhutchings |
last post by:
Hello everyone,
I have a database where I collect shipment data from various tables.
However, I have a problem. Whenever I want to see shipping data for
orders that were set to ship on or before a certain date (in this case
January 30th) the database will return 2 rows for an order as you can
see below.
Order ID: Line: Due Date: Qty: Ship Qty: Part #: Shipped:
141285 1 1/30/2006 31 10 S15F-55
| |
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 below. My problem is if I don’t use the WHERE clause in my script below, the script can query up to 3 records with the same “LoanNo” due to the fact that there can be up to 3 “TypeCodes” in each Table (Borrower, Co-Borrower 1 and Co-Borrower 2...
|
by: csolomon |
last post by:
Hello:
I am using two queries to get one result set. The issue is, I return no data when I combine them into one query. I have listed both queries, as well as the 3rd query that shows them combined.
**Max Date/Time Query-Finds the most recent updated record based on the time and date (Correct Results Returned)
SELECT .panelNumber, Max(.locDate) AS MaxOflocDate, Max(.completionTime) AS MaxOfcompletionTime, .jobNumber, .panelID
FROM , ...
|
by: bips2005 |
last post by:
i have got two queries,
$sql1 = "select cust_id from customer where comp_name = '$compname'";
$result = $DB->query($sql1);
$result->fetchInto($row);
$sql = "select expirydate from customer l,domain s where l.cust_id = '$row' and s.domname = '$domname'";
the first query retrieves cust_id from the table customer and i use it in the second query to obtain expirydate.
|
by: LSGKelly |
last post by:
Hi all. I need to combine two fields that contain numbers that are in a currency format (Ex: $1,500 $3,500). When I combine them, I want them to look like this -- $1,500/$3,500. When I combine them in the query, they look like this 1500/3500. Is there a way to combine and retain the currency format?
Thank you!
Kelly
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |