What am I missing?

Gasman

Enthusiastic Amateur
Local time
Today, 20:01
Joined
Sep 21, 2011
Messages
17,251
Hi all,
I am really puzzled by this, so must be doing something stupid, but cannot see what it is?

I have a table of trades and want only those for the 26/05/2016 and their totals?
I've created the query whose code is

Code:
SELECT [SVS Comms].Date, [SVS Comms].[Buy/Sell], [SVS Comms].[Trade Type], Sum([SVS Comms].[Share Cost]) AS [SumOfShare Cost], Sum(Round([Share Cost]*0.02,2)) AS TCComm, [SVS Comms].Stock
FROM [SVS Comms]
GROUP BY [SVS Comms].Date, [SVS Comms].[Buy/Sell], [SVS Comms].[Trade Type], [SVS Comms].Stock
HAVING ((([SVS Comms].Date)=#5/26/2016#) AND (([SVS Comms].[Buy/Sell])="buy") AND (([SVS Comms].[Trade Type])="AIM")) OR ((([SVS Comms].[Trade Type])="BONDS"));
Yet I get every date in the table grouped and totalled?


What am I missing please?
 

Attachments

  • Query Design.jpg
    Query Design.jpg
    95 KB · Views: 80
  • Result.jpg
    Result.jpg
    100.6 KB · Views: 106
You need to repeat the date and buy criteria on the second line, or use an In() clause for type. As is, you're mixing And & Or.
 
You need to repeat the date and buy criteria on the second line, or use an In() clause for type. As is, you're mixing And & Or.

Thank you Paul.

I generally create a query via the design window and found that I had to add the Buy and Type as Where options and not include fields in result.
That pretty much duplicates what you have indicated when writing it from scratch.

Need to practice more. :-(
 
That would also work. Wasn't sure if you needed them in the result.
 

Users who are viewing this thread

Back
Top Bottom