Crosstab Qry From Union Qry
Dec 6, 2005
I have a UNION qry in which I have Out, Incoming and internal invoices as RELATIONSHIPs, and based on it a CROSSTAB qry, and now there are 2 new categories which are goods that were returned - and there are 2 because:
1. is return from Internal and
2. is return from Outgoing invoices.
I need to calculate the current InStock (based on articalNumbers) with this in mind:
InStock = Incoming - OUTgoing - Internal + returnfromInternal + returnFromOutgoing
However, I cant seem to get a returns to the same crosstab qry in order to include them in calculation
the real names of variables are not important but the principle on which I should base my qry is the problem for me (please have in mind that I first started working in access about 2 months ago)
Is there anything wrong with the principle of my work here?
t i a...
View Replies
ADVERTISEMENT
Oct 9, 2013
I am trying to get a report that shows both column totals and row totals.
I have a crosstab query that gives me the Row totals along with the crosstab data.
I have read on a previous post [URL] ....
That I can union the crosstab to a select query which should get me what I want, but to be honest I am lost.
View 3 Replies
View Related
Oct 24, 2013
I'm having a problem with a UNION / UNION ALL query.It seems there is a application crash fault when running the query that MS are aware of and have issued a hot fix. Unfortunately it will take my IT dept some time to check and install the hot fix If they agree to do it at all.
Problem signature:
Problem Event Name: APPCRASH
Application Name: MSACCESS.EXE
Application Version: 12.0.6606.1000
[code]...
View 1 Replies
View Related
Sep 21, 2007
Hi all, I am utterly unsure if what I want to do is even possible:
I have two crosstab queries, qryRewCOCredit and qryWrapCOCredit which show the changeover (CO) times for the specified machine when they are NOT zero. (all zero entries don't show up).
There are many cases when there is a CO for the Rewinder on a specific day, but not for the Wrapper, and vice versa.
I want to make another crosstab query which performs a calculation. To keep it simple:
If (RewCOCredit>WrapCOCredit) Then
5-RewCOCredit
Else 'WrapCOCredit>RewCOCredit
5-WrapCOCredit
Please help!!!
View 2 Replies
View Related
Mar 31, 2008
Hi,
Can anyone please tell me what I am doing wrong here?
SELECT *
from Qry_300_Sel_In Jan not Dec
UNION ALL
SELECT *
from Qry_301_Sel_In Apr not Dec
UNION ALL
SELECT *
from Qry_302_Sel_In Jul not Dec
UNION ALL SELECT *
Qry_303_Sel_In Oct not Dec;
It is telling me that my syntax is wron in the From clause - But I don't get it!
View 3 Replies
View Related
Nov 17, 2006
Hello again.
If anyone can help me it would be greatly appreciated.
I知 not sure shy I知 having so much trouble with this, but I知 sure that this will be a great learning opportunity for me.
I値l explain it two different ways, and that way hopefully it will make sense
First off I知 trying to take all the Companies I work with and get there Net Sales
Example:
Company 1 $1,625.25
Company 2 $6,782.12
ect
I have two queries
The first one is:
qrtySym_Global_ALL_and_SUBFILE_A3
The second one is:
FROM qrtySym_Global_ALL_and_SUBFILE_A4
Below is the Union Query I currently have, and it puts together both queries and shows the totals separately
I would like it to show the Company Name and next to that the Net Sales for that company
SELECT "Total" , Sum(NETSALES)
FROM qrtySym_Global_ALL_and_SUBFILE_A3
union All
SELECT "Total" , Sum(NETSALES)
FROM qrtySym_Global_ALL_and_SUBFILE_A4
Let me see if I can explain it better
The are three columns in the two queries that are the same.
Company Business/ Company Name/Net Sales
I知 trying to take all the
A: Company Business that has the same name from query 1 and query 2 and merge them.
B: Company Name that has the same name from query 1 and query 2 and merge them.
C: Then with the merging of Company Business and the Company Name, Sum the total for the Net Sales.
I really appreciate you helping, so let me know if this doesn稚 make sense
Thanks
Corey
View 1 Replies
View Related
Aug 18, 2005
I have created a report that provides me with employee expenses for temps per week. The types of expenses have been defined as Ad_hoc amounts.
An SQL union query I have used to combine fields
Adhoc_Code_1 - 3
Adhoc_description_1 - 3
Adhoc_Pay_Amount_1 - 3
(details of full sql query below)
I have tried to run for a particular week which should have 3 expense entries but only 2 have been picked up.
I think this is because both Adhoc_ Pay_Amount_2 and 3 have a value of 6 and the UNION operation will not return duplicate records. I have amended to UNION ALL but all entries are duplicated. Can anyone help?
Thanks
SELECT dbo_Valid_Timesheets.Employer_Ref, dbo_Valid_Timesheets.Personnel_Ref, dbo_Valid_Timesheets.Department, dbo_Valid_Timesheets.Tax_Yr_Proc_By_Payroll, dbo_Valid_Timesheets.Period_Proc_By_Payroll, dbo_Valid_Timesheets.Session_Proc_By_Payroll, dbo_Valid_Timesheets.Adhoc_Code_1, dbo_Valid_Timesheets.Adhoc_Description_1, dbo_Valid_Timesheets.Adhoc_Pay_Amount_1, dbo_Valid_Timesheets.Timesheet_Number
FROM dbo_Valid_Timesheets
WHERE (((dbo_Valid_Timesheets.Adhoc_Pay_Amount_1)<>0));
UNION ALL
SELECT dbo_Valid_Timesheets.Employer_Ref, dbo_Valid_Timesheets.Personnel_Ref, dbo_Valid_Timesheets.Department, dbo_Valid_Timesheets.Tax_Yr_Proc_By_Payroll, dbo_Valid_Timesheets.Period_Proc_By_Payroll, dbo_Valid_Timesheets.Session_Proc_By_Payroll, dbo_Valid_Timesheets.Adhoc_Code_2, dbo_Valid_Timesheets.Adhoc_Description_2, dbo_Valid_Timesheets.Adhoc_Pay_Amount_2, dbo_Valid_Timesheets.Timesheet_Number
FROM dbo_Valid_Timesheets
WHERE (((dbo_Valid_Timesheets.Adhoc_Pay_Amount_2)<>0));
UNION ALL
SELECT dbo_Valid_Timesheets.Employer_Ref, dbo_Valid_Timesheets.Personnel_Ref, dbo_Valid_Timesheets.Department, dbo_Valid_Timesheets.Tax_Yr_Proc_By_Payroll, dbo_Valid_Timesheets.Period_Proc_By_Payroll, dbo_Valid_Timesheets.Session_Proc_By_Payroll, dbo_Valid_Timesheets.Adhoc_Code_3, dbo_Valid_Timesheets.Adhoc_Description_3, dbo_Valid_Timesheets.Adhoc_Pay_Amount_3, dbo_Valid_Timesheets.Timesheet_Number
FROM dbo_Valid_Timesheets
WHERE (((dbo_Valid_Timesheets.Adhoc_Pay_Amount_3)<>0));
UNION ALL SELECT dbo_EE_Payment_History.Employer_Ref, dbo_EE_Payment_History.Personnel_Ref, dbo_Payslip_Static_Data.Department, dbo_EE_Payment_History.Tax_Year, dbo_EE_Payment_History.Tax_Period, dbo_EE_Payment_History.Tax_Session, dbo_EE_Payment_History.Payment_Ref, dbo_EE_Payment_History.Type, Val([Payment_Value]) AS [Value], "" AS Timesheet
FROM dbo_EE_Payment_History INNER JOIN dbo_Payslip_Static_Data ON (dbo_EE_Payment_History.Tax_Session = dbo_Payslip_Static_Data.Session_Number) AND (dbo_EE_Payment_History.Tax_Period = dbo_Payslip_Static_Data.Period_Number) AND (dbo_EE_Payment_History.Tax_Year = dbo_Payslip_Static_Data.Tax_Year) AND (dbo_EE_Payment_History.Personnel_Ref = dbo_Payslip_Static_Data.Personnel_Ref) AND (dbo_EE_Payment_History.Employer_Ref = dbo_Payslip_Static_Data.Employer_Ref)
WHERE (((dbo_EE_Payment_History.Tax_Year)=[Forms]![Misc]![year]) AND ((dbo_EE_Payment_History.Tax_Period)=[Forms]![Misc]![period]) AND ((dbo_EE_Payment_History.Tax_Session)=[Forms]![Misc]![session]) AND ((dbo_EE_Payment_History.Payment_Ref)=777));
UNION ALL SELECT dbo_EE_Payments.Employer_Ref, dbo_EE_Payments.Personnel_Ref, dbo_Payslip_Static_Data.Department, [Forms]![Misc]![year] AS Tax_Year, [Forms]![Misc]![period] AS Tax_Period, [Forms]![Misc]![session] AS Tax_Session, dbo_EE_Payments.Payment_Ref, dbo_EE_Payments.X_Type, Val([Calculated_Value]) AS [Value], "" AS Timesheet
FROM dbo_EE_Payments INNER JOIN dbo_Payslip_Static_Data ON (dbo_EE_Payments.Personnel_Ref = dbo_Payslip_Static_Data.Personnel_Ref) AND (dbo_EE_Payments.Employer_Ref = dbo_Payslip_Static_Data.Employer_Ref)
WHERE (((dbo_EE_Payments.Payment_Ref)=777));
View 10 Replies
View Related
May 19, 2005
OK, so I am UNIONing two tables using UNION ALL. It works fine. The resultant table has 192 records (63 + 129).
If a use just UNION or UNION DISTINCT I get 184 records. I'm pretty sure that is telling me that 8 records (192 - 184) exist in both tables.
How do I query to find out what those 8 records are?? I'm trying to use an INTERSECT in MS Access, but it doesn't want to work. Here is my original query:
select * from qryMOE_Active_All
UNION ALL select * from qryMOE_Closed_All;
Thanks,
Brian
View 3 Replies
View Related
Sep 15, 2005
I have a query that requires a selection from my list box "[Forms]![ViewReports]![ListFilterName]"
I have a list box with a UNION so that I can query all contacts. The bound column is one.
SELECT 0,"<<ALL","TEAM MEMBERS>>" from Contacts UNION (SELECT Contacts.ID, Contacts.[First Name], Contacts.[Last Name] FROM Contacts ORDER BY [Last Name]);
Problems
The list is not ordering by last name.
The query does not assume all contacts when "<<ALL","TEAM MEMBERS>>" is selected.
Where did I go wrong? What's missing?
View 2 Replies
View Related
Sep 26, 2005
I am a basic access user so please forgive my ignorance. I have created a union query of three tables. There is one field from the third table that I would like to have in the final table but this field does not exist in the first table. If I put "none" in the first SELECT line, then it queries correctly but the field name on the table is "Expr1006". If I put "Field 2" or [Field 2] in that same space of the first SELECT line, then it asks me for a parameter value and whatever I enter it fills in all the cells of that field with that value. I just don't know that language very well or even if you can add a new field into the first SELECT table. Thank you for any thoughts
Ex: SELECT [Field 1], [Field 2], "none", [Field 3]
FROm [Table 1]
UNION
SELECT [Field 1], "none", [Field 2], [Field 3]
FROM [Table 2]
View 3 Replies
View Related
Feb 18, 2006
How do I use the union all command to combine 3 queries together and create a new field. I am trying to create a search that will combine the names in 3 fields and let me select any of them and pull up the records that are associated with that person.
I have written a database for an apartment complex. I am trying to simpify the search capabilities. They have 3 types of tenants, listed as HT-Head Tenant, CT-Co-Tenant & CT2- Co-Tenant 2. These fields are in a data base with all the info that applies to each apartment. I would like to be able to search from one combo box any of these tenants and have the correct information come up. Some one told me to use 3 queries and the SQL Union all command to get the fields combined into one field. But I can't get that to work. I am kind of a rookie as I have taught myself to do this so I might not be doing something correct. I was also told by doing the above steps I could use the ID field at the bound field. But not sure How to accomplish that either.
Appreciate any help I can get.
Thanks
View 3 Replies
View Related
Mar 16, 2006
Hello All,
I need help with an Union All Query. It is ignoring the second select statement. Can anyone see what I am doing wrong?
SELECT
CEPM_PLGR.COST_ELEM_CTGY AS [COST_ELEM_CTGY]
, CEPM_PLGR.PROJ_ELEM_ID AS [PROJ_ELEM_ID]
, CEPM_PLGR.COST_ELEM AS [COST_ELEM]
, CEPM_PLGR.SUM_UNIT AS [SUM_UNIT]
, CEPM_PLGR.PRD AS [PRD]
, CEPM_PLGR.CUR_BUD AS [CUR_BUD]
, CEPM_PLGR.PRD_BUD AS [PRD_BUD]
, CEPM_PLGR.CURRENT_ACT AS [CURRENT_ACT]
, CEPM_PLGR.PERIOD_ACT AS [PERIOD_ACT]
, CSIOWNER_PELM.PROJ_ELEM_DESC AS [PROJ_ELEM_DESC]
, CSIOWNER_PELM.PROJ_ELEM_MGR AS [PROJ_ELEM_MGR]
, CSIOWNER_PELM.PROJ_ELEM_TYPE AS [PROJ_ELEM_TYPE]
, NULL AS [COMMIT GA]
, CSIOWNER_PELM.COST_STAT AS [COST_STAT]
, CSIOWNER_PELM.PROJ_NBR AS [PROJ_NBR]
,NULL AS [COMMIT $]
FROM
CEPM_PLGR INNER JOIN CSIOWNER_PELM ON CEPM_PLGR.PROJ_ELEM_ID = CSIOWNER_PELM.PROJ_ELEM_ID
WHERE
((CSIOWNER_PELM.PROJ_TYPE)<>"T&M" And (CSIOWNER_PELM.PROJ_TYPE)<>"T7M") AND ((CSIOWNER_PELM.COST_MODE)="D")
AND ((CEPM_PLGR.PROJ_ELEM_ID)<>" ")
UNION ALL SELECT
NULL AS [COST_ELEM_CTGY]
, NULL AS [PROJ_ELEM_ID]
, NULL AS [COST_ELEM]
, NULL AS [SUM_UNIT]
, NULL AS [PRD]
, NULL AS [CUR_BUD]
, NULL AS [PRD_BUD]
, NULL AS [CURRENT_ACT]
, NULL AS [PERIOD_ACT]
, NULL AS [PROJ_ELEM_DESC]
, NULL AS [PROJ_ELEM_MGR]
, NULL AS [PROJ_ELEM_TYPE]
, (IIf( [PROJECT ID] Like "N0160*" And "N8100*" And "N9004*"
,(NZ([COMMIT $],0))
,(NZ([COMMIT GA $],0)))) AS [COMMIT GA]
, NULL AS [COST_STAT]
, NULL AS [PROJ_NBR]
, [PURCHASE_COMMITMENTS_FINAL].[COMMIT $] AS [COMMIT $]
FROM
[PURCHASE_COMMITMENTS_FINAL]
WHERE [PURCHASE_COMMITMENTS_FINAL].[PROJECT ID]
IN
(SELECT CEPM_PLGR.PROJ_ELEM_ID AS [PROJ_ELEM_ID]
FROM
CEPM_PLGR INNER JOIN CSIOWNER_PELM ON CEPM_PLGR.PROJ_ELEM_ID = CSIOWNER_PELM.PROJ_ELEM_ID
WHERE
((CSIOWNER_PELM.PROJ_TYPE)<>"T&M" And (CSIOWNER_PELM.PROJ_TYPE)<>"T7M") AND ((CSIOWNER_PELM.COST_MODE)="D")
AND ((CEPM_PLGR.PROJ_ELEM_ID)<>" ")) AND (([PURCHASE_COMMITMENTS_FINAL].[PROJECT ID]) <> " ");
I think it is my where clause IN function. But I do not know how to fix it. any help would be great!!!!
Thanks in advanced, Kerrie
View 2 Replies
View Related
Jul 11, 2006
To fill a ddl list I could use a MINUS query. I found out that UNION and UNION ALL work, but MINUS doesn't.
Is there a way to make it work, or maybe an other way to solve this kind of problem?
View 1 Replies
View Related
Jul 18, 2006
Hi Everyone.
I need help with union queries. The database that i am working with has union queries within it. I need to added information from a certain table into this query so that i can have a report generate more information when it is run. Please help if anyone knows how to work with union queries, or where i can go to find information on this.
Thank you:confused:
View 1 Replies
View Related
Aug 3, 2006
Okay, people. I am getting married in a few days and my mind is on other things. Consequently, I can't get my head around this one.
I have two queries, Query1 and Query2. Both have a different number of fields but they have the field "IA Code" in common.
I want to create a new query containing all rows from Query1 and all rows from Query2. Where the [IA Code] matches, I'd like the information to be displayed in one row.
I think I need to use Union somewhere along the lines, but I can't work it out.
Any pointers/syntax greatly appreciated.
View 1 Replies
View Related
Oct 6, 2006
I have a question regarding union queries, for the most part I understand them. You have to have the same amount of fields in both tables/queries, but what I do not know is do both tables/queries need to mimic each other 100%.
For example I have 2 Queries, both match each other identically in terms of fields and the order they are placed. What does not match is that I have one query with a "true" criteria under one field and the other query has a "true" in a seperate field.
When the query is ran I get "The number of colums in the two selected tables or queries of a union query do no match."
What is the purpose of the query, I am needing to combine these 2 queries into 1 for a report. If you need the code just ask and I shall post it.
Thanks ahead of time guys.
View 2 Replies
View Related
Jan 25, 2007
I have 2 tables with employee details in it. There is no natural link between the 2. I wish to write a query that will sum up the total pay for both tables.
I've had a look through the forum and it seems that a Union query is probably best.
I haven't worked with Unions before, so I did 2 sub queries to total the pay in both table and then union the 2 queries. I did this because there are some date parameters that I query each table by so I do this in the sub queries.
This works but I get 2 outputs in the result, the total pay from each table. I wanted to have just one output, which is the sum of all pay.
Can anyone help please.
SQL:
SELECT QrySub_TotalPay1.TotalPay 'sub query that sums up table 1
FROM QrySub_TotalPay1
UNION SELECT QrySub_TotalPay2.TotalPay 'sub query that sums up table 2
FROM QrySub_TotalPay2;
TIA.
View 3 Replies
View Related
Apr 24, 2007
I have 2 tables and I m trying to get sum of qty for each product
I tried union qurey following way but doesn't work.
Product_Master table has primary key set up on productcode. I need to pick up OpeningBal along with ProductName and ProductCode from this table.
T_PurInvFoot table contains multiple records of the similar ProductCode. I want to make sum of these PurQty data and add it with OpeningBal data from Product_master table and present it in one line.
The avalable quanities are in 2 diff. tables are here.
Product_Master.OpeningBal=5
(1 Record)
T_PurInvFoot.PurQty =4
T_PurInvFoot.PurQty =6
(2 Records)
So total it should be 15 when it produce records. But it show only 10 records from below query.
SELECT Product_Master.ProductCode, Product_Master.ProductName,Sum(Product_Master.Open ingBal) as Stock
From Product_Master INNER JOIN T_PurInvFoot ON T_PurInvFoot.ProductCode=Product_Master.ProductCod e
Group By Product_Master.ProductCode,Product_Master.ProductN ame
UNION Select T_PurInvFoot.ProductCode, T_PurInvFoot.ProductName, sum(T_PurInvFoot.PurQty) as Stock
From T_PurInvFoot INNER JOIN Product_Master ON T_PurInvFoot.ProductCode=Product_Master.ProductCod e
Group By T_PurInvFoot.ProductCode,T_PurInvFoot.ProductName
ORDER BY Product_Master.ProductCode;
Can somebody advice me how to do it.
I need to add 3rd table here in future to get sum of the qty of the similar ProductCode so how to the query would be?
One more thing, can we do it in VBA and set the RecordSource to a form or report ?
With kind regards,
Ashfaque
View 1 Replies
View Related
Oct 11, 2007
Hello All,
What I am trying to do is if the field (CAR) or (PAR) or (Incident) is checked in this table (Inventory Worksheet) then show it. I not sure how to use the union query to accomplish this.
Any Ideas?
Thanks,
View 5 Replies
View Related
Oct 12, 2007
I have two tables with data and I want to join the data together for a report.
Example:
SELECT tbl1.a tbl1.b tbl1.c tbl1.d
FROM tbl1
UNION SELECT tbl2.a tbl2.b tbl2.c
FROM tbl2;
Currently I can't join them b/c the column counts aren't the same.
If table1 has more columns than table2 can I join them by indicating some kind of phantom column 'd' for table2 to be joined to column 'd' of table1?
View 3 Replies
View Related
Dec 13, 2007
Will you help me built a union query ? I have 2 queries, qryinput and qryoutput.Out of these query i have a third query called qryDiff substracting these
queries. However qryDiff does not show all the goods sold, only those goods that are substracted.Therefore i want to build an union query but somehow i cannot do it. Will you help ?
My first query, qryinput is :
SELECT [order details].ProductID, Sum([order details].Quantity) AS Sum1, orders.orderid
FROM (orders INNER JOIN [order details] ON orders.orderid = [order details].OrderID) INNER JOIN products ON [order details].ProductID = products.Productid
GROUP BY [order details].ProductID, orders.orderid;
My second query, qryoutput is :
SELECT [order details].ProductID, orders.orderid, [order details].Quantity AS Sum2
FROM ((orders INNER JOIN [order details] ON orders.orderid = [order details].OrderID) INNER JOIN Customers ON orders.customerid = Customers.Customerid) INNER JOIN products ON [order details].ProductID = products.Productid;
My thirs query, qryDiff is :
SELECT qryProducts.ProductID, Sum(qryInput.Sum1) AS imported, Sum(qryOutput.Sum2) AS exported
FROM (qryProducts LEFT JOIN qryInput ON qryProducts.ProductID = qryInput.ProductID) LEFT JOIN qryOutput ON qryProducts.ProductID = qryOutput.ProductID
GROUP BY qryProducts.ProductID;
Now i want to convert the query qryDiff into an union query, but i cannot do it.I somehow managed to build a simple query showing all the products:
SELECT ProductID
FROM qryInput
UNION SELECT ProductID
FROM qryOutput;
This query shows the productsid indeed, but i cannot add the other items form the qryinput and qryoutput as the sum etc.
I also i cannot convert my query qryDiff into an uinion query, with fields for the imported and the exported sums and also for the product names.
Where is my error and now could i achieve my aim? My aim is that in the query qryDiff to show all the products, and not only the products sold.
I will be very grateful for any comments
View 6 Replies
View Related
Dec 30, 2007
I have 2 tables, Employees and Customers. Each table has a column called active.
How can I make a union query that will return all active employees and customers?
View 1 Replies
View Related
Mar 23, 2008
Hello friends
How are you
Please I need help in Union Queries
what does this code mean
"SELECT [Query_buy] ,Type.[Query_buy].Sum0 ,no AS InQuin , "Return" as Description From [Query_buy]"
I need to make combined report shows the reteurnd items.
I hope that my words are enough clear
Thank you all
View 1 Replies
View Related
Sep 23, 2004
I have two tables - one of staff and one of activities. I want to assign each new activity to a member of staff based on a unique ref and then want the other related fields to be filled in automatically. i.e. I select the staff ID from a lookup using a combo box and a forename and surname field in the activity table is then immediately populated with the right details from the staff table. I think the animal I need for this is a union query but apparently I need to code some SQL to do this and let's just say my SQL leaves a bit to be desired!
View 2 Replies
View Related
Mar 16, 2005
I have a two tables
Employee
TokenID
Division
Band
PMRating
H1
Now i want to get average H1 ratings of all the employees who belong to division 'PDRDS' and group them along with the 'Band' level ( i.e Managerial, officer, UnitLeader etc..)
Now here i would like to display the H1 ratings for all the Band levels irrespective of the division criteria. Even if there is noemployee from 'PDRDS' division within that 'Band' level.
In short i want all the bands within all the divisions without restricting it to the division..
Code: SELECT Avg(PMRating.H1) AS AvgOfH1, Employee.Band, Count(Employee.TokenID) AS CountOfTokenIDFROM Employee LEFT JOIN PMRating ON Employee.TokenID = PMRating.TokenIDWHERE (((Employee.Division)='PDRDS'))GROUP BY Employee.Band;
if i make sense ..please do help
any help will do
thanx a lot
View 9 Replies
View Related
Dec 13, 2007
Will you help me built a union query ? I have 2 queries, qryinput and qryoutput.Out of these query i have a third query called qryDiff substracting these
queries. However qryDiff does not show all the goods sold, only those goods that are substracted.Therefore i want to build an union query but somehow i cannot do it. Will you help ?
My first query, qryinput is :
SELECT [order details].ProductID, Sum([order details].Quantity) AS Sum1, orders.orderid
FROM (orders INNER JOIN [order details] ON orders.orderid = [order details].OrderID) INNER JOIN products ON [order details].ProductID = products.Productid
GROUP BY [order details].ProductID, orders.orderid;
My second query, qryoutput is :
SELECT [order details].ProductID, orders.orderid, [order details].Quantity AS Sum2
FROM ((orders INNER JOIN [order details] ON orders.orderid = [order details].OrderID) INNER JOIN Customers ON orders.customerid = Customers.Customerid ) INNER JOIN products ON [order details].ProductID = products.Productid;
My thirs query, qryDiff is :
SELECT qryProducts.ProductID, Sum(qryInput.Sum1) AS imported, Sum(qryOutput.Sum2) AS exported
FROM (qryProducts LEFT JOIN qryInput ON qryProducts.ProductID = qryInput.ProductID) LEFT JOIN qryOutput ON qryProducts.ProductID = qryOutput.ProductID
GROUP BY qryProducts.ProductID;
Now i want to convert the query qryDiff into an union query, but i cannot do it.I somehow managed to build a simple query showing all the products:
SELECT ProductID
FROM qryInput
UNION SELECT ProductID
FROM qryOutput;
This query shows the productsid indeed, but i cannot add the other items form the qryinput and qryoutput as the sum etc.
I also i cannot convert my query qryDiff into an uinion query, with fields for the imported and the exported sums and also for the product names.
Where is my error and now could i achieve my aim? My aim is that in the query qryDiff to show all the products, and not only the products sold.
I will be very grateful for any comments
View 3 Replies
View Related