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:

[![Duplicate](https://i.stack.imgur.com/IPceP.png)](https://i.stack.imgur.com/IPceP.png)

For example I have these two tables

Table a

[![table a](https://i.stack.imgur.com/67U4j.png)](https://i.stack.imgur.com/67U4j.png)

Table 2

[![table 2](https://i.stack.imgur.com/cJL9s.png)](https://i.stack.imgur.com/cJL9s.png)

But I need to display only one member\_id with the latest registered\_time