I have a query and I need to display distinct values from a join. I have this kind of SQL query
select
a.member_id, b.registered_time
from
b
left join
(select distinct a.member_id from a) on b.mirror_id = a.mirror_id
order by
b.registered_time desc;
But this query returns me a syntax error
Incorrect syntax near the keyword 'on'
How can I fix that?
I also tried doing this query but it returns an error
Invalid column name 'mirror_id'
Code:
select
a.member_id, b.registered_time
from
b
left join
(select distinct a.member_id from a) a on b.mirror_id = a.mirror_id
order by
b.registered_time desc;
I also tried doing this kind
select
a.member_id, b.registered_time
from
b
left join
(select distinct a.member_id from a) AP on b.mirror_id = a.mirror_id
order by
b.registered_time desc;
but it returns an error that multipart identifier couldn't be bound
I have these kind of result from my join:
For example I have these two tables
Table a
Table 2
But I need to display only one member_id with the latest registered_time