473,797 Members | 3,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3425
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!S tartDate and Forms!SaleRpt!E ndDate

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
1985
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` varchar(50) default NULL, `subject` varchar(255) default NULL,
3
6192
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 a Customer Table :
10
2457
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 current query lists addresses with two particular types ('MN30D843J2', 'SC93JDL39D'). I need to change this to (1) check each contact for address type 'AM39DK3KD9' and then (2) if the contact has type 'AM39DK3KD9' select types ('AM39DK3KD9',...
5
1500
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 those 2 fields are null prior to the beginning date of my parameter. The reason for this (to help make this a little clearer)is to pull production into a query if it is a 'new' for the month. That is, never run before the dates entered. I have 2...
26
2180
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 "points" Now, I also have a table called all_matches. This table contains every match report. Over 25,000 of them. I have a "username" field an "outcome" field an "username1" field and "extra_match" field.
4
1628
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 average for columnX where columnY=Z so i started of course with select avg(columnX) as avg1, avg(columnX) as avg2 from table where columnY=Z
8
1968
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 need it to loop through the table and do everything where data_store_no matches $store_no. I've tried placing where at a couple different points with no real success - it either doesn't work at all, exceeds the time allowed for a process...
2
2056
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 write a query which should give me records : 1. Where there is missing Exc_Ref value in either of the table. i.e. If Trade table has a Exc_Ref value but missing in Cons table then that
3
1139
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 query that will show me only the previous 3 diary entries sorted by date.
2
3235
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 'Total' FROM TTmain INNER JOIN TTdealers ON
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10469
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10246
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10209
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9066
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.