ms access - I get the following error "at most one record can be returned by this subquery" -


this code meant pull status projects, 2 recent dates , return projects 3 last report , recent report. keep getting error 1 record can returned sub query , query takes forever run. please help.

select redprojecthistorical.[project name] (     select          'project name',     max('report date') maxrd     redprojecthistorical     group redprojecthistorical.'project name' ) redprojecthistorical  3 = (     select         t2.[internal project status value]      redprojecthistorical t2              t2.[project name] = redprojecthistorical.[project name]          , t2.[report date] = redprojecthistorical.maxrd )  , 3 = (     select top 1 t2.[internal project status value]      redprojecthistorical t2               t2.[project name] = redprojecthistorical.[project name]          , t2.[report date] <redprojecthistorical.maxrd      order t2.[report date] desc ); ` 

try use exists condition this:

exists(select 1   redprojecthistorical t2   t2.[project name] = redprojecthistorical.[project name]      , t2.[report date] = redprojecthistorical.maxrd     , t2.[internal project status value] = 3) 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -