Connecting Tech Pros Worldwide Forums | Help | Site Map

How to query database with multiple queries

Cady Steldyn
Guest
 
Posts: n/a
#1: Nov 13 '05

I have the following fieldname in an Access_Table:

Field 1 = Cust_ID (Primary key)
Field 2 = Date
Field 3 = Description
Field 4 = Inv_No
Field 5 = Amount

My SQL Input syntax are:

"Select distinct Cust_ID,Date,Description,Inv_No,Amount from
Access_Table WHERE Date <Now()-30 And Date >Now()-60 AND Date =
Main.Date"

It failed to generate the result I want,anyway

My "Required" Output is:

Cust_ID Date Description Inv_No >30DYS >60DYS
8000 21/05/2004 PC RAM 200
8000 26/06/2004 Modem 180
---------------------------------------------------------------
Total: 180 200
---------------------------------------------------------------

8001 22/04/2004 Cable 50
8001 23/05/2004 HD 210
---------------------------------------------------------------
Total: 260
---------------------------------------------------------------
Grand Total: 180 460


can anyone help? Thanks
From:Cady Steldyn



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jeff Smith
Guest
 
Posts: n/a
#2: Nov 13 '05

re: How to query database with multiple queries


Hi Cady,
One problem you're having here is calling a field with the name of "Date"
which is a reserved word in Access. Rename this field to DatePaid or
StartDate or DateProcessed etc. This give the field name more uniqueness and
at a quick glance, anybody can understand what the purpose of the field is
for.

With your SQL syntax and using the "Date" field renamed to DatePaid
***Warning Untested Air Code***
SELECT Cust_ID, DatePaid, Description, Inv_No, Amount
FROM Access_Table
WHERE DatePaid Between DateAdd("d", -60, Date()) And DateAdd("d", -30,
Date());

The Date() function represents the current date while the Now() function
represents the current date and current time.

Jeff


"Cady Steldyn" <dcartford@yahoo.ca> wrote in message
news:4143d123$0$26156$c397aba@news.newsgroups.ws.. .[color=blue]
>
> I have the following fieldname in an Access_Table:
>
> Field 1 = Cust_ID (Primary key)
> Field 2 = Date
> Field 3 = Description
> Field 4 = Inv_No
> Field 5 = Amount
>
> My SQL Input syntax are:
>
> "Select distinct Cust_ID,Date,Description,Inv_No,Amount from
> Access_Table WHERE Date <Now()-30 And Date >Now()-60 AND Date =
> Main.Date"
>
> It failed to generate the result I want,anyway
>
> My "Required" Output is:
>
> Cust_ID Date Description Inv_No >30DYS >60DYS
> 8000 21/05/2004 PC RAM 200
> 8000 26/06/2004 Modem 180
> ---------------------------------------------------------------
> Total: 180 200
> ---------------------------------------------------------------
>
> 8001 22/04/2004 Cable 50
> 8001 23/05/2004 HD 210
> ---------------------------------------------------------------
> Total: 260
> ---------------------------------------------------------------
> Grand Total: 180 460
>
>
> can anyone help? Thanks
> From:Cady Steldyn
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


Closed Thread