Dates are throwing off my query (1 Viewer)

ethan.geerdes

Registered User.
Local time
Today, 11:54
Joined
Jun 4, 2015
Messages
116
I am trying to build a query that will count how many times a song plays and sums the listeners for that song during the month. I currently have this as a live csv worksheet that is linked to the access form. The fields are date, artist, title, listeners. I got the query to work correctly if I don't include the date in the query but as soon as I add the date field, it only counts and sums everything for that day. The reason I want to be able to have the date in there is because, I'm trying to let the end user open up the application, select the start date and end date to generate a custom report.


Am I approaching this wrong?
 

plog

Banishment Pending
Local time
Today, 13:54
Joined
May 11, 2011
Messages
11,638
Please provide the SQL and some sample data that the query returned demonstrating the issue.
 

ethan.geerdes

Registered User.
Local time
Today, 11:54
Joined
Jun 4, 2015
Messages
116
Below is the sql that isn't working

SELECT [Sound-exchange-report].date, [Sound-exchange-report].artist, [Sound-exchange-report].title, Count([Sound-exchange-report].[title]) AS Spins, Sum([Sound-exchange-report].[listeners]) AS TotalListeners
FROM [Sound-exchange-report]
GROUP BY [Sound-exchange-report].date, [Sound-exchange-report].artist, [Sound-exchange-report].title
ORDER BY [Sound-exchange-report].date;

The result is that it counts and totals for the day.

And this one is the code that works without the date.

SELECT [Sound-exchange-report].artist, [Sound-exchange-report].title, Count([Sound-exchange-report].title) AS Spins, Sum([Sound-exchange-report].listeners) AS TotalListeners
FROM [Sound-exchange-report]
GROUP BY [Sound-exchange-report].artist, [Sound-exchange-report].title;
 

theDBguy

I’m here to help
Staff member
Local time
Today, 11:54
Joined
Oct 29, 2018
Messages
21,454
Hi Ethan. Sounds like you're also grouping on the date field when what you wanted to do was make it a Where clause.


Edit: Oops, too slow. I posted the above before I saw the SQL statement you just posted.
 

Users who are viewing this thread

Top Bottom