By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,574 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,574 IT Pros & Developers. It's quick & easy.

Parameterized query from within query

P: n/a
Hey Guys,

I hope I didn't miss a post on this subject already.

I am using Access 2003 through ADO.

I have query 1 (MergeThisLastSeason):

SELECT m2.MemberLevelDesc, m2.CostAmt, m1.MemberLevelID, m1.SeasonID
FROM MemberLevels AS m2 INNER JOIN MemberLevels AS m1 ON
m2.CurrSeasMbrID=m1.MemberLevelID
where m1.SeasonID = [@aseasonid]

and query 2:

SELECT
Sum(InvoiceItems.ItemQty) AS SumOfItemQty,
MergeThisLastSeason.MemberLevelDesc,
MergeThisLastSeason.CostAmt,
Sum(MergeThisLastSeason.CostAmt) AS TotAmt,
InvoiceItems.PersonID, InvoiceItems.SeasonID
FROM MergeThisLastSeason
INNER JOIN InvoiceItems ON
MergeThisLastSeason.MemberLevelID=InvoiceItems.Mem berLevelID
WHERE MergeThisLastSeason.SeasonID=InvoiceItems.SeasonID
GROUP BY MergeThisLastSeason.MemberLevelDesc,
MergeThisLastSeason.CostAmt, InvoiceItems.PersonID,
InvoiceItems.PersonID, InvoiceItems.SeasonID;

I used to have [@aseasonid] hard coded to a value but now I want it as
a parameter

How do I get query 2 to execute query 1 (MergeThisLastSeason) with a
parameter?

Dazed and confused,

~Gina_M~
Feb 26 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Feb 25, 10:36*pm, Gina_Marano <ginals...@gmail.comwrote:
Hey Guys,

I hope I didn't miss a post on this subject already.

I am using Access 2003 through ADO.

I have query 1 (MergeThisLastSeason):

SELECT m2.MemberLevelDesc, m2.CostAmt, m1.MemberLevelID, m1.SeasonID
FROM MemberLevels AS m2 INNER JOIN MemberLevels AS m1 ON
m2.CurrSeasMbrID=m1.MemberLevelID
where m1.SeasonID = [@aseasonid]

and query 2:

SELECT
Sum(InvoiceItems.ItemQty) AS SumOfItemQty,
MergeThisLastSeason.MemberLevelDesc,
MergeThisLastSeason.CostAmt,
Sum(MergeThisLastSeason.CostAmt) AS TotAmt,
InvoiceItems.PersonID, InvoiceItems.SeasonID
FROM MergeThisLastSeason
INNER JOIN InvoiceItems ON
MergeThisLastSeason.MemberLevelID=InvoiceItems.Mem berLevelID
WHERE MergeThisLastSeason.SeasonID=[@seasonid]
GROUP BY MergeThisLastSeason.MemberLevelDesc,
MergeThisLastSeason.CostAmt, InvoiceItems.PersonID,
InvoiceItems.PersonID, InvoiceItems.SeasonID;

I used to have [@aseasonid] hard coded to a value but now I want it as
a parameter

How do I get query 2 to execute query 1 (MergeThisLastSeason) *with a
parameter?

Dazed and confused,

~Gina_M~
please disregard thanks much!!!
Feb 26 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.