Re: Retrive informations fro two lists
From: Douglas J. Steele (NOSPAM_djsteele_at_NOSPAM_canada.com)
Date: 02/27/05
- Next message: ATanker62: "Selecting data to run a query by using a drop down list"
- Previous message: Chris2: "Access SUMs Full Column When Using Subquery"
- In reply to: Nils Magne: "Retrive informations fro two lists"
- Next in thread: Nils Magne: "Re: Retrive informations fro two lists"
- Reply: Nils Magne: "Re: Retrive informations fro two lists"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 27 Feb 2005 14:11:06 -0500
Are you saying that you want the sum?
Create a query that unions the two lists together:
SELECT [item#], [name], Nz([qty], 0) As quantity
FROM [List 1]
UNION ALL
SELECT [item#], [name], Nz([qty], 0) As quantity
FROM [List 2]
Call that qryUnion
Create a second query that sums that up:
SELECT [item#], [name], Sum([quantity]) As qty
FROM qryUnion
GROUP BY [item#], [name]
In fact, if you're using Access 2000 or newer, you can do this in a single
query:
SELECT [item#], [name], SUM(quantity) AS qty
FROM
(SELECT [item#], [name], nz(qty, 0) AS quantity
FROM [List 1]
UNION
SELECT [item#], [name], nz(qty, 0) AS quantity
FROM [List 2])
GROUP BY [item#], [name]
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Nils Magne" <loevrak@online.no> wrote in message news:83A71A8D-EE8A-4E99-AEA1-CA9AA13D9F01@microsoft.com... > Hey, > I have a problem, namely to retrive all informations form two lists, the > problem is that when one or more itms ar missing in bout lists: > List 1 > item# name qty > 1 A 2 > 3 C > 4 D 1 > > List 2 > 1 A 5 > 2 B > 3 C > 4 D 7 > 6 F 5 > > Result - which I am not able to retain > item# name qty > 1 A 7 > 2 B > 3 C > 4 D 8 > 6 F 5 > > Anyone? > -- > > Nils Magne Løvrak (Norway)
- Next message: ATanker62: "Selecting data to run a query by using a drop down list"
- Previous message: Chris2: "Access SUMs Full Column When Using Subquery"
- In reply to: Nils Magne: "Retrive informations fro two lists"
- Next in thread: Nils Magne: "Re: Retrive informations fro two lists"
- Reply: Nils Magne: "Re: Retrive informations fro two lists"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|