Re: insert variables into Query
- From: stephenson22 <stephenson22@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 31 Oct 2006 05:40:02 -0800
"Qtr_Value" is calcualated and I have found a way to do this.
All I need to know now is how do I substitue the tableY.EndDate into the
Query for each row in the tableY.
I want to get out of inserting subqueries simply to change one common value.
--
Learning SQL and Access
"Jeff Boyce" wrote:
A couple observations/questions....
Where are you getting your [Qtr_Value]? Is that a calculated value, based
on the date in your [EndDate] field? If so, a scan through this (queries)
and the tablesdbdesign newsgroups will show a strong consensus against
storing calculated values. If you can calculate it, do that, in a query
(this isn't an "ALWAYS" condition, but "USUALLY").
If you are storing text like "06-07 Qtr2", how are you proposing to compare
that to a date. You use
fieldB >= tableY.EndDateas a WHERE condition, and I assume your "fieldB" is your [Qtr_Value].
--
Regards
Jeff Boyce
Microsoft Office/Access MVP
http://mvp.support.microsoft.com/
Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
Microsoft Registered Partner
https://partner.microsoft.com/
"stephenson22" <stephenson22@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B7395BF6-DD86-4FAC-9AE6-1C11495D81F9@xxxxxxxxxxxxxxxx
I have a query: simple extract below.of
---------------------------------------------------------------
select
fieldA
fieldB
tableY.Qtr_Value
from tableX
where
fieldA <= tableY.EndDate
And
fieldB >= tableY.EndDate
-----------------------------------------------------------
..........follow me so far :o)
I have a table (tableY) with the follwing values:
EndDate Qtr_Value
31/09/06 06-07 Qtr2
30/06/06 06-07 Qtr1
31/03/06 05-06 Qtr4
For every occurrance of a row in tableY I would like to insert the value
EndDate into the SQL query above and for each iteration insert the
corresponding value of Qtr_Value in the SQL query the desired result after
two iterations would look like this:
SQL iteration 1:
-------------------------
select
fieldA
fieldB
tableY.Qtr_Value
from tableX
where
fieldA <= 31/09/06
And
fieldB >= 31/09/06
Result 1:
fieldA, fieldB, Qtr_Value
value, value 2, 06-07 Qtr2
SQL interation 2
-------------------------
select
fieldA
fieldB
tableY.Qtr_Value
from tableX
where
fieldA <= 30/06/06
And
fieldB >= 30/06/06
Result 2:
fieldA, fieldB, Qtr_Value
value, value 2, 06-07 Qtr1
I hope I have made this clear enough for a genius to help me.
Please, please, please :o)
--
Learning SQL and Access
- Follow-Ups:
- Re: insert variables into Query
- From: Jeff Boyce
- Re: insert variables into Query
- References:
- Re: insert variables into Query
- From: Jeff Boyce
- Re: insert variables into Query
- Prev by Date: Re: insert variables into Query
- Next by Date: Access 2003 Copy a record when a field contains three entries
- Previous by thread: Re: insert variables into Query
- Next by thread: Re: insert variables into Query
- Index(es):
Relevant Pages
|