Re: How to make a query choose the last three years
- From: "Ofer Cohen" <chamudim@xxxxxxxxxxx>
- Date: Mon, 25 Jun 2007 11:28:55 +0300
My mistake, the order in the between should have the small value first
SELECT Avg([P&P_tbl].[P&P_%]) AS [Avg], [P&P_tbl].[ID#], [Emp_Courses_tbl
Query].[Sum Of Mark], [Sum Of Mark]/25 AS [% of Course], [Avg]+[% of
Course]/100 AS [Total %]
FROM [Emp_Courses_tbl Query] INNER JOIN [P&P_tbl] ON [Emp_Courses_tbl
Query].[ID#] = [P&P_tbl].[ID#]
WHERE [P&P_tbl].[Year] Between Year(Date())-3 And Year(Date())
GROUP BY [P&P_tbl].[ID#], [Emp_Courses_tbl Query].[Sum Of Mark]
"Jon" <Jon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C3313335-3B05-49B0-82B8-DB96C229DA31@xxxxxxxxxxxxxxxx
hi,[Emp_Courses_tbl
still does not work
"Ofer Cohen" wrote:
Hi Jon,
If the Year field contain only the Year and not a full date, try:
SELECT Avg([P&P_tbl].[P&P_%]) AS [Avg], [P&P_tbl].[ID#],
namesQuery].[Sum Of Mark], [Sum Of Mark]/25 AS [% of Course], [Avg]+[% of
Course]/100 AS [Total %]
FROM [Emp_Courses_tbl Query] INNER JOIN [P&P_tbl] ON [Emp_Courses_tbl
Query].[ID#] = [P&P_tbl].[ID#]
WHERE [P&P_tbl].[Year] Between Year(Date()) And Year(Date())-3
GROUP BY [P&P_tbl].[ID#], [Emp_Courses_tbl Query].[Sum Of Mark]
Note: It's not recomended using build in functions in Access as fields
changing(Year - that will return the year from the date).
It will be OK as long that you place it in square brackets, but to avoid
errors and to have to remember puting square brackets, it's better
[Emp_Courses_tblthe name.
------
Good Luck
BS"D
"Jon" <Jon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2675357E-D56C-4895-B4B1-DB5C1A08F869@xxxxxxxxxxxxxxxx
Thank you all for your cooperation
This is what I did
But it did not work
This is my sql after rplace Date() with 2006 after that it worked
SELECT Avg([P&P_tbl].[P&P_%]) AS [Avg], [P&P_tbl].[ID#],
Query].[Sum Of Mark], [Sum Of Mark]/25 AS [% of Course], [Avg]+[% of
Course]/100 AS [Total %]
FROM [Emp_Courses_tbl Query] INNER JOIN [P&P_tbl] ON [Emp_Courses_tbl
Query].[ID#] = [P&P_tbl].[ID#]
WHERE ((([P&P_tbl].Year) Between 2006 And DateAdd("yyyy",-3,Date())))
GROUP BY [P&P_tbl].[ID#], [Emp_Courses_tbl Query].[Sum Of Mark];
"Chris2" wrote:
"Jon" <Jon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CF7CCD8C-E27D-4CA0-A5F2-15B9BCDF571F@xxxxxxxxxxxxxxxx
does not work
Jon,
What error did you receive and what was the SQL code you used?
Sincerely,
Chris O.
.
- References:
- Re: How to make a query choose the last three years
- From: Chris2
- Re: How to make a query choose the last three years
- From: Ofer Cohen
- Re: How to make a query choose the last three years
- From: Jon
- Re: How to make a query choose the last three years
- Prev by Date: Re: How to make a query choose the last three years
- Next by Date: Re: how to select between two values in table
- Previous by thread: Re: How to make a query choose the last three years
- Next by thread: Help with time formatting.Please!
- Index(es):
Relevant Pages
|