I'm very new to using sub queries. When running the following query, the column t_num and timestamp is NULL whereas in the respective table those columns have values.
Table trans contains multiple p_num, trans_amt, trans_balance. I just want to get the transaction that happened before 31-JULY-2017 and before.
select
p.p_number,
p.name,
t.t_num,
t.timestamp
from payers p
left join (
select p_number, t_num, timestamp from trans a
where a.timestamp <= '31-JUL-2017' and rownum = 1
order by a.timestamp desc
) t on t.p_number = p.p_number
where p.p_number in(44545558, 44545559, 44545560, 44545561, 44545562)
Result
I tried just running this portion of the query and I can see the t_num and timestamp column values.
select p_number, t_num, timestamp from trans a
where a.timestamp <= '31-JUL-2017' and rownum = 1
order by a.timestamp desc

p_numberfrom the list you pass toINin the complete query? I'd guess no.'31-JUL-2017'is a string not a timestamp, you should compare data types properly and not rely on implicit conversion and NLS settings; and yourrownumfiltering isn't right as the ordering happens too late. Neither of which is necessarily relevant... but please include the table DDL; particularly, what are the data types of the twop_numbercolumns? Your output suggests they might strings and that could cause a problem, but that might just be from how you created/generated your image. (And please post text rather than images...)ONclause of the left join. And that's why the columns stay null.