sql - Subquery in access with self-join, it does not recognize table alias -
i built subquery:
select q2.addedquests, q2.daynum qrnumberofqueststodo q2 inner join qrnumberofqueststodo q3 on q2.daynum > q3.daynum q2.daynum = (select max(q3.daynum) q3);
but ms access not recognize q3
in subquery. why?
why not? because how sql works. can refer column of q3
in subquery (in select
, where
, group by
, having
, order by
, or on
clause instance), not entire table.
i continuing, think query non-sensical. in 1 place, query says q2.daynum > q3.daynum
. in another, q2.daynum = q3.daynum
. hence, query not return anything. but, can still express valid sql. notice q3
not needed in outer query. try correlated subquery instead:
select q2.addedquests, q2.daynum qrnumberofqueststodo q2 q2.daynum = (select max(q3.daynum) qrnumberofqueststodo q3 q2.daynum>q3.daynum ) ;
Comments
Post a Comment