Prompting for date range twice

L

Love Buzz

Hi all.

I have a query that I am creating to compare volumes to previous day
averages. What I am trying to do is have the query prompt me twice for a
date range. The first prompt will be a specific date and the second will be
a range of days. From those results I want to compare the daily volume to
the average of the range of days I have selected.

Here is what I have now and obviously I am not getting the result I am
looking for. Any ideas? Thanks for your help.

SELECT [Incoming Return Item Detail].DepositingAccount, Count([Incoming
Return Item Detail].ReturnReason) AS CountOfReturnReason,
[CountOfReturnReason] AS Expr1
FROM [RCC Customer List] INNER JOIN [Incoming Return Item Detail] ON [RCC
Customer List].[Account #] = [Incoming Return Item Detail].DepositingAccount
WHERE ((([Incoming Return Item Detail].Date) Between [Start Date] And [End
Date]) AND (([Incoming Return Item Detail].Date) Between [Start Date] And
[End Date]))
GROUP BY [Incoming Return Item Detail].DepositingAccount;
 
K

KARL DEWEY

Try this --
SELECT [Incoming Return Item Detail].[Date], [Incoming Return Item
Detail].DepositingAccount, [Incoming Return Item Detail].[ReturnReason],
Count([Incoming Return Item Detail].ReturnReason) AS CountOfReturnReason
FROM [RCC Customer List] INNER JOIN [Incoming Return Item Detail] ON [RCC
Customer List].[Account #] = [Incoming Return Item Detail].DepositingAccount
WHERE [Incoming Return Item Detail].[Date] Between [Start Date] And [End
Date]
GROUP BY [Incoming Return Item Detail].[Date], [Incoming Return Item
Detail].[DepositingAccount], [Incoming Return Item Detail].[ReturnReason];
 
L

Love Buzz

Thank you Karl for responding. I receive a Syntax Error in JOIN Operation
when I run that SQL.

KARL DEWEY said:
Try this --
SELECT [Incoming Return Item Detail].[Date], [Incoming Return Item
Detail].DepositingAccount, [Incoming Return Item Detail].[ReturnReason],
Count([Incoming Return Item Detail].ReturnReason) AS CountOfReturnReason
FROM [RCC Customer List] INNER JOIN [Incoming Return Item Detail] ON [RCC
Customer List].[Account #] = [Incoming Return Item Detail].DepositingAccount
WHERE [Incoming Return Item Detail].[Date] Between [Start Date] And [End
Date]
GROUP BY [Incoming Return Item Detail].[Date], [Incoming Return Item
Detail].[DepositingAccount], [Incoming Return Item Detail].[ReturnReason];

--
KARL DEWEY
Build a little - Test a little


Love Buzz said:
Hi all.

I have a query that I am creating to compare volumes to previous day
averages. What I am trying to do is have the query prompt me twice for a
date range. The first prompt will be a specific date and the second will be
a range of days. From those results I want to compare the daily volume to
the average of the range of days I have selected.

Here is what I have now and obviously I am not getting the result I am
looking for. Any ideas? Thanks for your help.

SELECT [Incoming Return Item Detail].DepositingAccount, Count([Incoming
Return Item Detail].ReturnReason) AS CountOfReturnReason,
[CountOfReturnReason] AS Expr1
FROM [RCC Customer List] INNER JOIN [Incoming Return Item Detail] ON [RCC
Customer List].[Account #] = [Incoming Return Item Detail].DepositingAccount
WHERE ((([Incoming Return Item Detail].Date) Between [Start Date] And [End
Date]) AND (([Incoming Return Item Detail].Date) Between [Start Date] And
[End Date]))
GROUP BY [Incoming Return Item Detail].DepositingAccount;
 
K

KARL DEWEY

I just tried it without an error.

Check for returns inserted in the copy/paste/posting process. There should
only be a return before the FROM, WHERE, and BROUP BY.
--
KARL DEWEY
Build a little - Test a little


Love Buzz said:
Thank you Karl for responding. I receive a Syntax Error in JOIN Operation
when I run that SQL.

KARL DEWEY said:
Try this --
SELECT [Incoming Return Item Detail].[Date], [Incoming Return Item
Detail].DepositingAccount, [Incoming Return Item Detail].[ReturnReason],
Count([Incoming Return Item Detail].ReturnReason) AS CountOfReturnReason
FROM [RCC Customer List] INNER JOIN [Incoming Return Item Detail] ON [RCC
Customer List].[Account #] = [Incoming Return Item Detail].DepositingAccount
WHERE [Incoming Return Item Detail].[Date] Between [Start Date] And [End
Date]
GROUP BY [Incoming Return Item Detail].[Date], [Incoming Return Item
Detail].[DepositingAccount], [Incoming Return Item Detail].[ReturnReason];

--
KARL DEWEY
Build a little - Test a little


Love Buzz said:
Hi all.

I have a query that I am creating to compare volumes to previous day
averages. What I am trying to do is have the query prompt me twice for a
date range. The first prompt will be a specific date and the second will be
a range of days. From those results I want to compare the daily volume to
the average of the range of days I have selected.

Here is what I have now and obviously I am not getting the result I am
looking for. Any ideas? Thanks for your help.

SELECT [Incoming Return Item Detail].DepositingAccount, Count([Incoming
Return Item Detail].ReturnReason) AS CountOfReturnReason,
[CountOfReturnReason] AS Expr1
FROM [RCC Customer List] INNER JOIN [Incoming Return Item Detail] ON [RCC
Customer List].[Account #] = [Incoming Return Item Detail].DepositingAccount
WHERE ((([Incoming Return Item Detail].Date) Between [Start Date] And [End
Date]) AND (([Incoming Return Item Detail].Date) Between [Start Date] And
[End Date]))
GROUP BY [Incoming Return Item Detail].DepositingAccount;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Query with multiple criteria 1
Expression is to complicated? 7
Average Records between date range 10
Two queueries - same table - different totals 1
Sum and Join 1
Counting Query 2
Counting '*' in a query 3
Asterix 4

Top