dbTalk Databases Forums  

QUERY

comp.databases.ms-access comp.databases.ms-access


Discuss QUERY in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
DS
 
Posts: n/a

Default QUERY - 12-17-2004 , 01:57 PM






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

Reply With Quote
  #2  
Old   
MGFoster
 
Posts: n/a

Default Re: QUERY - 12-17-2004 , 02:29 PM






DS wrote:
Quote:
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:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQcNBVYechKqOuFEgEQKIzwCfab2TPEOLeUtTse8/peixGsEP8XAAoJii
jrlh6GiVu51CrdINxJE/aOoQ
=sF1t
-----END PGP SIGNATURE-----


Reply With Quote
  #3  
Old   
strauss.sean@gmail.com
 
Posts: n/a

Default Re: QUERY - 12-17-2004 , 02:29 PM



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...


Reply With Quote
  #4  
Old   
DS
 
Posts: n/a

Default Re: QUERY - 12-17-2004 , 02:35 PM



strauss.sean (AT) gmail (DOT) com wrote:
Quote:
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


Reply With Quote
  #5  
Old   
DS
 
Posts: n/a

Default Re: QUERY - 12-17-2004 , 02:37 PM



MGFoster wrote:

Quote:
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


Reply With Quote
  #6  
Old   
MGFoster
 
Posts: n/a

Default Re: QUERY - 12-17-2004 , 02:54 PM



DS wrote:
Quote:
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:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

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

iQA/AwUBQcNHaoechKqOuFEgEQLDkgCeKYGtgLItkyxP4ntS21RHEy T0InEAoOJw
HWn0xxgTXvThSbZZOmuhSrDw
=+FhC
-----END PGP SIGNATURE-----


Reply With Quote
  #7  
Old   
Fred Zuckerman
 
Posts: n/a

Default Re: QUERY - 12-17-2004 , 04:03 PM



"DS" <bootybox (AT) optonline (DOT) net> wrote

Quote:
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




Reply With Quote
  #8  
Old   
Bob Quintal
 
Posts: n/a

Default Re: QUERY - 12-17-2004 , 05:33 PM



DS <bootybox (AT) optonline (DOT) net> wrote in
news:ysHwd.1230$aq2.620 (AT) fe08 (DOT) lga:

Quote:
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_Description
FROM Sales
WHERE Item_Key NOT IN
(SELECT Item_Key
FROM Sales
WHERE DateDiff("d",SalesDate, date()) < 20)


--
Bob Quintal

PA is y I've altered my email address.


Reply With Quote
  #9  
Old   
DS
 
Posts: n/a

Default Re: QUERY - 12-18-2004 , 09:09 AM



Fred Zuckerman wrote:
Quote:
"DS" <bootybox (AT) optonline (DOT) net> wrote in message
news:wTGwd.1219$u52.107 (AT) fe08 (DOT) lga...

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


Reply With Quote
  #10  
Old   
DS
 
Posts: n/a

Default Re: QUERY - 12-18-2004 , 11:49 AM



Fred Zuckerman wrote:
Quote:
"DS" <bootybox (AT) optonline (DOT) net> wrote in message
news:wTGwd.1219$u52.107 (AT) fe08 (DOT) lga...

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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.