On 5 Apr 2019, at 2:45pm, Jose Isaias Cabrera <[email protected]> wrote:

> then do this,
> 
> select
> a.*, b.* from t as a join z as b on a.a = b.f
> where a.a = 'p006'
> AND
>  a.idate = (select max(idate) from t where a = a.a)
> AND
>  b.idate = (select max(idate) from z where f = a.a)
> ORDER BY a.a
> ;

For testing purposes, break your SELECT down into single operations.  First do

select max(idate) from t where a = 'p006'
select max(idate) from z where f = 'p006'

Are those values the answers you expected ?  Then plug those answers into

> select
> a.*, b.* from t as a join z as b on a.a = b.f
> where a.a = 'p006'
> AND
>  a.idate = X
> AND
>  b.idate = Y
> ORDER BY a.a

and see whether it does what you expect.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to