Query results

bknight
BronzeLounger
Posts: 1391
Joined: 08 Jul 2016, 18:53

Query results

Post by bknight »

This query is from a Db I use daily. The results are not what I expected.

Code: Select all

SELECT Sum(Trades.Dividends) AS SumOfDividends
FROM Trades
GROUP BY Trades.Filled, Trades.Filled, Trades.Type, Trades.Symbol
HAVING ((Month([filled])=3) AND (Year([filled])=2024) AND ((Trades.Type)="Dividend"));
I was expecting a single sum and I see 10 "sums"

User avatar
Gasman
2StarLounger
Posts: 104
Joined: 22 Feb 2022, 09:04

Re: Query results

Post by Gasman »

1. Why do you have Fillled twice?
2. Not much to help with if we do not see the output? :sad:

I am going to guess that one or more of those fields are different?
Using Access 2007/2019.
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Please, please use code tags when posting code snippets, click the </>icon.
Debug.Print is your lifesaver.

User avatar
HansV
Administrator
Posts: 78510
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Query results

Post by HansV »

Does this do what you want?

SELECT Sum(Trades.Dividends) AS SumOfDividends
FROM Trades
WHERE ((Month([filled])=3) AND (Year([filled])=2024) AND ((Trades.Type)="Dividend"));
Best wishes,
Hans

bknight
BronzeLounger
Posts: 1391
Joined: 08 Jul 2016, 18:53

Re: Query results

Post by bknight »

HansV wrote:
29 Mar 2024, 14:08
Does this do what you want?

SELECT Sum(Trades.Dividends) AS SumOfDividends
FROM Trades
WHERE ((Month([filled])=3) AND (Year([filled])=2024) AND ((Trades.Type)="Dividend"));
Yes it does, thanks