SQLite Forum

Not understanding a subquery - Some guidance?
Login
Simon,

Thanks for the reply.

Interesting thought but sub select refers to outer select....hmmm trying to redo i came up with:

select r.ritm, t.task, t.ud from t t 
left outer join r r on t.ritm = r.ritm limit 1
order by date(t.ud) desc;

which gives an error becuase of limit 1 clause so executing without limit clause:

select r.ritm, t.task, t.ud from t t 
left outer join r r on t.ritm = r.ritm
order by date(t.ud) desc;

which then I get:

r1|t3|2021-01-03
r1|t2|2021-01-02
r1|t1|2021-01-01
r2|t4|2021-01-01

which is wrong for two things.  One is I only want the first row of t where it matches r on ritm and two I would like to see r3 from r and nulls for fields joining on t.

Is there another way to just test the subselect?

Thanks,
Jeff