473,378 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

month over month decline query

I am trying to construct a query that sums sales by salespersons and
only returns a list of salespersons that have a sum of sales lower than
the previous month for whatever date rane is selected.
For example, if the user selects a date range of Sept.1 ,2004 thru Dec.
31, 2004 the query will return only salespersons where October was
worse than September and November was worse than october and December
was worse than November...

Is ths possible?

The basic query is:

SELECT Contacts.UniqueID, Contacts.LastName, Sum(Sales.Amount) AS
SumOfAmount
FROM Contacts LEFT JOIN Sales ON Contacts.UniqueID = Sales.UniqueID
WHERE (((Sales.SaleDate) Between [Enter a Starting Date:] And [Enter an
Ending Date:]))
GROUP BY Contacts.UniqueID, Contacts.LastName;

Nov 13 '05 #1
1 1319
laurenq uantrell wrote:
I am trying to construct a query that sums sales by salespersons and
only returns a list of salespersons that have a sum of sales lower than
the previous month for whatever date rane is selected.
For example, if the user selects a date range of Sept.1 ,2004 thru Dec.
31, 2004 the query will return only salespersons where October was
worse than September and November was worse than october and December
was worse than November...

Is ths possible?


Strict descending, is that called it?
I think it is possible.

A first step may be selecting all pairs of months where one month (date)
is smaller than the other, but the sum of sales is larger. I would limit
this to the date range you supply.

The second step is finding salesperson for who all possible month pairs
occur in the result of the first step. You are interested in only those
pairs where the months differ by just one, but that is not different in
this set.

Does that make sense?

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by...
10
by: Jim | last post by:
I'm sure this has been asked before but I can't find any postings. I have a table that has weekly inspections for multiple buildings. What I need to do is break these down by the week of the...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
6
by: Dynash | last post by:
i want to have a normal hyperlink, its for the terms of service, a i accept, and i decline. the i decline like i want it to have the onClick="closeIt()" in order for when someone clicks the i...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.