O
owp^3
I have an append query that loads a temporary table with the rank order of
projects within status groups based upon a score.
I am loading a temporary table because of how slow these kinds of queries
are. The query works fine but management wants certain projects to rank
higher than others based on a second criteria. Since it is a specific value
they are looking for I can't use it to group on.
Here is the query that currently works:
INSERT INTO
staging_StagingRank ( ProjectID, ProjectStatus, ProjectScore,
MRE_CurrentRank )
SELECT
select_MREStaging.MRE_ProjectID,
select_MREStaging.MRE_CurrentStatus,
select_MREStaging.MRE_Score,
(SELECT Count(*) FROM select_MREStaging AS Stag
WHERE Stag.MRE_Score > select_MREStaging.MRE_Score AND
Stag.MRE_CurrentStatus =
select_MREStaging.MRE_CurrentStatus)+1
AS MRE_CurrentRank
FROM select_MREStaging
So this creates a 1 to N rank within each Status Group.
The additional rule is any Project that has a MRE_PlanYear value of "2008P"
should have a rank of zero. All of the other projects should be ranked
against each other according to their score.
I tried adding AND Stag.MRE_PlanYear <> "2008P" to the subquery but that
didnt work. I also tried an IIF with the subquery as the ELSE parameter and
that didn't work either.
I'd appreciate any advice folks can send my way.
Thanks,
owp^3
projects within status groups based upon a score.
I am loading a temporary table because of how slow these kinds of queries
are. The query works fine but management wants certain projects to rank
higher than others based on a second criteria. Since it is a specific value
they are looking for I can't use it to group on.
Here is the query that currently works:
INSERT INTO
staging_StagingRank ( ProjectID, ProjectStatus, ProjectScore,
MRE_CurrentRank )
SELECT
select_MREStaging.MRE_ProjectID,
select_MREStaging.MRE_CurrentStatus,
select_MREStaging.MRE_Score,
(SELECT Count(*) FROM select_MREStaging AS Stag
WHERE Stag.MRE_Score > select_MREStaging.MRE_Score AND
Stag.MRE_CurrentStatus =
select_MREStaging.MRE_CurrentStatus)+1
AS MRE_CurrentRank
FROM select_MREStaging
So this creates a 1 to N rank within each Status Group.
The additional rule is any Project that has a MRE_PlanYear value of "2008P"
should have a rank of zero. All of the other projects should be ranked
against each other according to their score.
I tried adding AND Stag.MRE_PlanYear <> "2008P" to the subquery but that
didnt work. I also tried an IIF with the subquery as the ELSE parameter and
that didn't work either.
I'd appreciate any advice folks can send my way.
Thanks,
owp^3