Actually, John's SQL should have been:
SELECT Bags.ItemCode, Count(*) AS TotalCount, Sum([Weight]) AS TotalWeight
FROM Bags INNER JOIN ItemDetail ON Bats.ItemCode = ItemDetail.ItemCode
GROUP BY Bags.ItemCode
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"berni" <(E-Mail Removed)> wrote in message
news:33F9D22B-952A-4A40-B69D-(E-Mail Removed)...
> Will the GROUP BY build the running totals seperate for each group?
> If so i would need the same.
> Where did you add the GROUP BY in John W. Vinson SQL code?
>
> like that:
>
> SELECT Bags.ItemCode, Sum([Weight]) AS TotalWeight
> FROM Bags INNER JOIN ItemDetail ON GROUP BY Bats.ItemCode =
> ItemDetail.ItemCode;
>
> thx a lot for a reply ... im new to sql queries
>
>
>
> "David" wrote:
>
>> John
>>
>> No I had not actually tried one. I jumped to the wrong conclusion when I
>> saw
>> a microsoft KB on running totals queries where they used DSum not Sum and
>> when I had a look through microsoft.public.access.queries it seemed that
>> all
>> the totals queries used DSum.
>>
>> Your query seems to work well (I did have to add GROUP BY Bags.ItemCode)
>> and
>> the information is coming out a lot faster in the query than it did
>> before.
>>
>>
>> Thank you for your help
>> David
>>
>> "John W. Vinson" wrote:
>>
>> > On Thu, 18 Sep 2008 21:54:01 -0700, David
>> > <(E-Mail Removed)>
>> > wrote:
>> >
>> > >Thank you John
>> > >
>> > >I had a look at Totals Queries. They are based once again on DSum?
>> >
>> > No, they do not use dsum. Evidently you did not actually try one!
>> >
>> > >Is there something faster about using DSum in a query vs VBA?
>> >
>> > VBA would certainly slow things down considerably - just another layer
>> > of
>> > complexity!
>> >
>> > >
>> > >My table structure is quite simple
>> > >1) ItemCode - This identifies the item in another table and is a
>> > >1-many
>> > >relationship with my items table
>> > >2) Weight - Weight of item
>> > >3) ID - Identifies individual item within item grouping
>> > >
>> > >To get my result of x items @ xx lbs I would use:
>> > >"Total = " & DCount("Weight","ItemDetail","Bags.Itemcode=" &
>> > >me.txtItemCode)
>> > >& "items @ " & DSum("Weight","ItemDetail","Bags.Itemcode=" &
>> > >me.txtItemCode)
>> > >& "lbs"
>> >
>> > What's the context? Where are you *using* these expressions? You can
>> > see your
>> > database - I cannot!
>> >
>> > >I have several different item ID's and I use them on a continuous form
>> > >that
>> > >shows an instant update on how many items in the item group and the
>> > >total
>> > >weight for them each.
>> >
>> > Try a Query:
>> >
>> > SELECT Bags.ItemCode, Count(*) AS TotalCount, Sum([Weight]) AS
>> > TotalWeight
>> > FROM Bags INNER JOIN ItemDetail ON Bats.ItemCode = ItemDetail.ItemCode;
>> >
>> > and base a report or form on this query. Adapt as needed for your table
>> > and
>> > fieldnames and relationships.
>> > --
>> >
>> > John W. Vinson [MVP]
>> >