简体   繁体   中英

Subquery using ANYELEMENT with Entity SQL

According to the Microsoft Documents ( http://msdn.microsoft.com/en-us/library/bb738573.aspx ) for Entity SQL in order to return a scalar subquery I need to use the function ANYELEMENT().

However, when I try that I am getting this as my returned values:

System.Data.Query.ResultAssembly.BridgeDataRecord

My query:

SELECT

ANYELEMENT(
SELECT SUM(CASE WHEN B.EXECUTION_STATUS_ID=2 THEN 1 ELSE 0 END)
    FROM SpiraTestEntities.R_TestCases AS B
    WHERE TruncateTime(B.EXECUTION_DATE) <= DateExecuted) AS PASSED,

DateExecuted


FROM SpiraTestEntities.R_TestCases as A

where A.PROJECT_ID = ${ProjectId}

AND A.IS_DELETED = false

AND A.EXECUTION_DATE IS NOT NULL

GROUP BY 

TruncateTime(A.EXECUTION_DATE) as DateExecuted

I should be getting something more like this:

PASSED      DateExecuted
------      ------------
   37       2014-06-05
   67       2014-06-06
   92       2014-06-09

But I'm getting this:

PASSED                                                      DateExecuted
------                                                      ------------
System.Data.Query.ResultAssembly.BridgeDataRecord            2014-06-05
System.Data.Query.ResultAssembly.BridgeDataRecord            2014-06-06
System.Data.Query.ResultAssembly.BridgeDataRecord            2014-06-09

Any ideas?

SELECT之后添加VALUE

ANYELEMENT(SELECT VALUE SUM(CASE WHEN ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM