473,406 Members | 2,208 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,406 software developers and data experts.

Complicated Select/Sum Query

Hi there! I am pretty new to Access, have been loving learning it! I
have a problem here I can't even begin to figure out. Here is what I
need:
Given 1 Date and 1 Store, retrieve the following information:

1. # of each product sold in STORE for DATE, and for the 3 days prior
to DATE
2. Sum # of each product sold in STORE for days 5-8 previous to DATE
3. Sum # of each product sold in STORE for days 9-12 previous to DATE
4. Sum # of each product sold in STORE for days 13-16 previous to DATE
5. Sum # of each product sold in STORE for days 17-32 previous to DATE
5. Sum # of each product sold in STORE for days 33-48 previous to DATE

So obviously this will be a bunch of queries grouped together. I can't
even get my head around where to start though, as I don't know how to
total X number of records at a time. Can anyone help point me in the
right direction please?
Much appreciated,
-Ted

Nov 13 '05 #1
2 3413
Can you post a summary of the table structure?

Nov 13 '05 #2
te*******@gmail.com wrote:
Hi there! I am pretty new to Access, have been loving learning it! I
have a problem here I can't even begin to figure out. Here is what I
need:
Given 1 Date and 1 Store, retrieve the following information:

1. # of each product sold in STORE for DATE, and for the 3 days prior
to DATE
2. Sum # of each product sold in STORE for days 5-8 previous to DATE
3. Sum # of each product sold in STORE for days 9-12 previous to DATE
4. Sum # of each product sold in STORE for days 13-16 previous to DATE
5. Sum # of each product sold in STORE for days 17-32 previous to DATE
5. Sum # of each product sold in STORE for days 33-48 previous to DATE

So obviously this will be a bunch of queries grouped together. I can't
even get my head around where to start though, as I don't know how to
total X number of records at a time. Can anyone help point me in the
right direction please?
Much appreciated,
-Ted

I might create a text box with the label along the lines of "How Many
Days Prior?" and the op fills in the number of days prior. 0 would be
the current date, 1 = yesterday, etc.

In order to assist the op, create a start/end date range. Drop 2 text
boxes; StartDate and EndDate onto the form. Open the property sheet and
set, under Data tab, Enabled to No, Locked to Yes so the ops can't
change the dates. Set the EndDate to default value to today. As in
=Date()

Then when the person enteres a DaysPrior value, have some code in the
AfterUpdate event along the lines of
Me.StartDate = DateAdd("d",Me.DaysPrior * -1,date())
This will now present to the op the data range you are getting data for.

I'll call this form SaleRpt and use it in the following. Change the
Between line to reflect your form name.

In your query, under the SaleDate field, enter something
Between Forms!SaleRpt!StartDate and Forms!SaleRpt!EndDate

This should start you off OK. I have a funny feeling that once folks
see the flexibility, they might want to enter their own date ranges.
Nov 13 '05 #3

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

Similar topics

4
by: John Pedersen | last post by:
Hi, I have this table: CREATE TABLE `messages` ( `messageID` int(11) unsigned NOT NULL auto_increment, `threadID` int(11) unsigned, `fromUserName` varchar(50) default NULL, `toUserName`...
3
by: Chris | last post by:
Hello all- Fairly new to SQL and I need to issue a pretty complex query (complex being a relative term here :) ). To dumb down my example for display purposes, I have two tables in my schema...
10
by: jqq | last post by:
SQL2K on W2Kserver I need some help revamping a rather complicated query. I've given the table and existing query information below. (FYI, changing the database structure is right out.) The...
5
by: Norma | last post by:
I am trying to make a query pull data from between the dates I enter in the parameter but also look back 'in time' to see where 2 other fields have null values, and only pull data into the query if...
26
by: Jeff | last post by:
Ok gang. Here is something complicated, well, at least to me anyway. Using Access DB I have a table in my DB called members. In that table, I have 2 tables I will be using "username" and...
4
by: Matthew Crouch | last post by:
i suck so much that i don't even know if this is a JOIN or a subquery or who-knows what. Here's the idea: I want to select two things at the same time (form one table) average for columnX and...
8
by: Nancy | last post by:
Greetings: First, I apologize if my posting format is improper. The code below does what I intended it to do, but presently only displays 1 table entry. I've grown it to this point, but really...
2
by: Nick | last post by:
Hi, I have two tables Trade table and Cons table. Records are inserted in both the tables independent of each other. There are fields like Exc_Ref, Qty, Date in both the tables. I need to...
3
by: z.ghulam | last post by:
Hi, I am trying to create a query from a table which has an ID, Diary and Date fields. A particular ID may have several diary entries which all have their specific date. What I'm after is a...
2
by: Joe C. | last post by:
hello, just joined the group, i've run into a wall and am seeking some help. here is my query: SELECT DATEPART(year, TTmain.TTDate) AS 'Year', SUM(TTmain.TTAmt) + SUM(TTmain.TTFee) AS...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.