473,549 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

QUERY

DS
I need to run a Query that returns Products wirh a Sale Date Older Than
20 Days and doesn't have a Sale Date of earlier than 20 Days, Any
Suggestions. I hope this clearer than my last post.
Thnaks
DS
Nov 13 '05 #1
9 1332
DS wrote:
I need to run a Query that returns Products wirh a Sale Date Older Than
20 Days and doesn't have a Sale Date of earlier than 20 Days, Any
Suggestions. I hope this clearer than my last post.
Thnaks
DS


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Not sure what you mean, but...

SELECT *
FROM Sales
WHERE SalesDate < Date() - 20

Date() - 20 means subtract 20 days from the current date. If the Sales
Date is less than that date then it is older than 20 days.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQcNBVYechKq OuFEgEQKIzwCfab 2TPEOLeUtTse8/peixGsEP8XAAoJi i
jrlh6GiVu51CrdI NxJE/aOoQ
=sF1t
-----END PGP SIGNATURE-----
Nov 13 '05 #2
I've seen this in the MS Access Cookbook, published by O'Reilly. (I
recommend this book highly!) I'll dig it out and post in an hour or
so...

Nov 13 '05 #3
DS
st**********@gm ail.com wrote:
I've seen this in the MS Access Cookbook, published by O'Reilly. (I
recommend this book highly!) I'll dig it out and post in an hour or
so...

Thanks,
I'm going crazy here!
DS
Nov 13 '05 #4
DS
MGFoster wrote:
DS wrote:
I need to run a Query that returns Products wirh a Sale Date Older
Than 20 Days and doesn't have a Sale Date of earlier than 20 Days, Any
Suggestions. I hope this clearer than my last post.
Thnaks
DS

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Not sure what you mean, but...

SELECT *
FROM Sales
WHERE SalesDate < Date() - 20

Date() - 20 means subtract 20 days from the current date. If the Sales
Date is less than that date then it is older than 20 days.

Yeah but the problem is that it doesn't take into account if theres a
sale made earlier. I need to set-up a Query that shows Products that
haven't sold in 20 Days or longer. I thought it would be easy!
Thnaks
DS
Nov 13 '05 #5
DS wrote:
MGFoster wrote:
DS wrote:
I need to run a Query that returns Products wirh a Sale Date Older
Than 20 Days and doesn't have a Sale Date of earlier than 20 Days,
Any Suggestions. I hope this clearer than my last post.
Thnaks
DS


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Not sure what you mean, but...

SELECT *
FROM Sales
WHERE SalesDate < Date() - 20

Date() - 20 means subtract 20 days from the current date. If the Sales
Date is less than that date then it is older than 20 days.

Yeah but the problem is that it doesn't take into account if theres a
sale made earlier. I need to set-up a Query that shows Products that
haven't sold in 20 Days or longer. I thought it would be easy!
Thnaks
DS


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You said "Sale Date Older Than 20 Days," that usually means product
hasn't sold in the last 20 days. That's why I said "Not sure what you
mean." Do you mean elapsed time (ET) between sales? E.g. (number of
days between sales for the dates 1/1/04 to 6/30/04):

Product ET (days)
widget 0
widget 15
widget 20
widget 30
dodad 0
dodad 5
dodad 10

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQcNHaoechKq OuFEgEQLDkgCeKY GtgLItkyxP4ntS2 1RHEyT0InEAoOJw
HWn0xxgTXvThSbZ ZOmuhSrDw
=+FhC
-----END PGP SIGNATURE-----
Nov 13 '05 #6
"DS" <bo******@opton line.net> wrote in message
news:wT******** ********@fe08.l ga...
I need to run a Query that returns Products wirh a Sale Date Older Than
20 Days and doesn't have a Sale Date of earlier than 20 Days, Any
Suggestions. I hope this clearer than my last post.
Thnaks
DS


I'll make an assumption that you have a table with item# and sale date, such
that the item# repeats every time you make a sale. And I suspect that you're
looking for any items that HAVEN'T been sold in the last 20 days but WERE
sold earlier.

I would create 2 queries, first, a select query with the following fields:
1) item#
2) sale date
3) OldSale: iif([sale date]<date()-20,1,0)
4) RecentSale: iif([sale date]<date()-20,0,1)

second, create a total query using query1 as the source. Add the following
fields:
1) item# as groupby
2) OldSale as sum, with criteria >0
3) RecentSale as sum, with criteria = 0

Does this give you the info that you want?
Fred Zuckerman
Nov 13 '05 #7
DS <bo******@opton line.net> wrote in
news:ys******** ********@fe08.l ga:
MGFoster wrote:
DS wrote:
I need to run a Query that returns Products wirh a Sale Date
Older Than 20 Days and doesn't have a Sale Date of earlier
than 20 Days, Any Suggestions. I hope this clearer than my
last post. Thnaks
DS

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Not sure what you mean, but...

SELECT *
FROM Sales
WHERE SalesDate < Date() - 20

Date() - 20 means subtract 20 days from the current date. If
the Sales Date is less than that date then it is older than
20 days.

Yeah but the problem is that it doesn't take into account if
theres a sale made earlier. I need to set-up a Query that
shows Products that haven't sold in 20 Days or longer. I
thought it would be easy! Thnaks
DS


Try:

SELECT DISTINCT
Item_Key
Item_Descriptio n
FROM Sales
WHERE Item_Key NOT IN
(SELECT Item_Key
FROM Sales
WHERE DateDiff("d",Sa lesDate, date()) < 20)
--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #8
DS
Fred Zuckerman wrote:
"DS" <bo******@opton line.net> wrote in message
news:wT******** ********@fe08.l ga...
I need to run a Query that returns Products wirh a Sale Date Older Than
20 Days and doesn't have a Sale Date of earlier than 20 Days, Any
Suggestions . I hope this clearer than my last post.
Thnaks
DS

I'll make an assumption that you have a table with item# and sale date, such
that the item# repeats every time you make a sale. And I suspect that you're
looking for any items that HAVEN'T been sold in the last 20 days but WERE
sold earlier.

I would create 2 queries, first, a select query with the following fields:
1) item#
2) sale date
3) OldSale: iif([sale date]<date()-20,1,0)
4) RecentSale: iif([sale date]<date()-20,0,1)

second, create a total query using query1 as the source. Add the following
fields:
1) item# as groupby
2) OldSale as sum, with criteria >0
3) RecentSale as sum, with criteria = 0

Does this give you the info that you want?
Fred Zuckerman

Thanks,
I'll give it a whirl!
DS
Nov 13 '05 #9
DS
Fred Zuckerman wrote:
"DS" <bo******@opton line.net> wrote in message
news:wT******** ********@fe08.l ga...
I need to run a Query that returns Products wirh a Sale Date Older Than
20 Days and doesn't have a Sale Date of earlier than 20 Days, Any
Suggestions . I hope this clearer than my last post.
Thnaks
DS

I'll make an assumption that you have a table with item# and sale date, such
that the item# repeats every time you make a sale. And I suspect that you're
looking for any items that HAVEN'T been sold in the last 20 days but WERE
sold earlier.

I would create 2 queries, first, a select query with the following fields:
1) item#
2) sale date
3) OldSale: iif([sale date]<date()-20,1,0)
4) RecentSale: iif([sale date]<date()-20,0,1)

second, create a total query using query1 as the source. Add the following
fields:
1) item# as groupby
2) OldSale as sum, with criteria >0
3) RecentSale as sum, with criteria = 0

Does this give you the info that you want?
Fred Zuckerman

Thanks Fred. It worked! Thanks also to everyone that responded.
Sincerely,
DS
Nov 13 '05 #10

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

Similar topics

2
3418
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the new values are updated in all corresponding tables (the function of the pages in question). However, on the page that does the DB update, I also...
29
2477
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules" for when and how to use single quotes and double quotes in ASP? thanks! ---------------------- SQL = SQL & "WHERE '" &...
9
3114
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be...
3
5373
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says there is a sample file called Ixtrasp.asp, but I could not find it in my system although I installed indexing service. I followed the steps in MSDN...
4
2135
by: Diamondback | last post by:
I have two tables, WIDGETS and VERSIONS. The WIDGETS table has descriptive information about the widgets while the VERSIONS table contains IDs relating to different iterations of those widgets over the years. The idea is that from any widget in the database you can look forward and backward to see different versions of the widget through...
14
3865
by: Dave Thomas | last post by:
If I have a table set up like this: Name | VARCHAR Email | VARCHAR Age | TINYINT | NULL (Default: NULL) And I want the user to enter his or her name, email, and age - but AGE is optional. My insert would look something like:
0
3487
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list boxes do not necessarily need to have a selection made to be used in the dynamic query. In essence the form can have selections made in all or...
6
4829
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID SalesManName AT Alan Time
4
3117
by: Stan | last post by:
I am using MS Office Access 2003 (11.5614). My basic question is can I run a query of a query datasheet. I want to use more that one criteria and can not get that query to work. I thought I might be able to accomplish the results in two steps by using two queries. If this is possible how can I do it? Thank you, Stan Hanna
6
4380
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one field between them. The join field in both tables are indexed and I'm selecting 1 field from each table to lookup. The Access query is taking more...
0
7542
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...
0
7467
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7982
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...
0
7827
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6066
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...
1
5385
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5110
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...
1
1961
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
1
1079
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.