Question: I have written a query to fetch records from an oracle table. But when I use a distinct function It goes into time out and does not give any results. Is there an alternative to using a distinct and still get results?

Only Test3 works without distinct. In Test2, I tried to use a subquery but doesn't work either.

In the sample of the table, there are more than 100k rows. But I have shown only 1 percent of it.

Table1:

```
id                     country
100003                 Poland
PL10005-100001         England
100007                 Finland 
100005                 Sweden
100004                 Norway
100002                 Chicago

```

Table2:

```
id                     country
100003                Poland
100007                Finland
100006                Austria
100004                Norway
100001                India

```

Test1:

```
SELECT
distinct
t1.id,
t2.country,
from table1 t1 inner join table2 t2 on t1.id = t2.id

```

Test2:

```
Select distinct
id, 
country
from 
(
select 
t1.id,
t2.country,
from table1 t1 inner join table2 t2 on t1.id = t2.id)

```

Test3:

```
SELECT
t1.id,
t2.country,
from table1 t1 inner join table2 t2 on t1.id = t2.id

```

Answer: 
By using the Cached view, I was able to fix this distinct view issue.
Your join statement has the wrong syntax. Try this:

```
SELECT
distinct
t1.id,
t2.country
from table1 t1 inner join table2 t2 on t1.id = t2.id

```