Everything works great until I need to return the "Rank" and "Percentile" information for a given record. It can not be expressed using my object-oriented model. I have two problems:
1. I need to execute native sql query.
2. I need to map the query result back to an object. And the mapping is not based a physical table column
Please shed a light on me. Thank you in advance!
Build 1.2.0.Alpha1
The table is:
create table dbo.tblGamePlayHistory (
pk_gamePlayHistoryId int identity(1,1) not null,
Role nvarchar(100),
QuizScore float,
CaseScore float
)
The query I need to execute is:
Code:
select Rank, (Rank*100)/(RecordCount+1) as Percentile, pk_gamePlayHistoryId, QuizScore, CaseScore from
(
select
(select count(g2.pk_gamePlayHistoryId)
from tblGamePlayHistory g2
where (g2.QuizScore + g2.CaseScore) > (g1.QuizScore + g1.CaseScore)
) +1 as Rank,
(select count(g3.pk_gamePlayHistoryId) from tblGamePlayHistory g3 where g3.QuizScore is not null and g3.QuizScore is not null) as recordCount,
g1.pk_gamePlayHistoryId,
g1.QuizScore,
g1.CaseScore
from tblGamePlayHistory g1
where g1.QuizScore is not null and g1.QuizScore is not null
) t
where t.pk_gamePlayHistoryId = 10
order by Rank