Question: ```py
@app.route('/')
def index():
    return render_template("home.html")

```

My folder structure looks like this

```
tree-/
   -static/
      -styles.css
   -templates/
      -home.html
   -app.py

```

I get

**Not Found**

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

On the browser and

```
127.0.0.1 - - [01/May/2021 09:41:47] "GET / HTTP/1.1" 404 -

```

In the debugger

Have looked at other related posts saying stuff about trailing slashes and it doesn't look like its making a difference, either I access
<http://127.0.0.1:5000>
or
<http://127.0.0.1:5000/>

I run my application using

```py
app = Flask(__name__)

if __name__ == '__main__':
    app.run()

```

I get

```py
 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

```

```py
from flask import Flask, redirect, url_for, render_template

app = Flask(__name__)

if __name__ == '__main__':
    app.run()

@app.route('/')
def index():
    return "Hello World"

```

Answer: 
Use conditional aggregation with a `having` clause:

```
select customer_id
from t
where location in ('Santa Clara', 'Milpitas')
group by customer_id
having max(store_entry) filter (where location = 'Santa Clara') >
       min(store_entry) filter (where location = 'Milpitas');

```

Your statement is that the customer when to *after* Santa Clara *after* Milpitas. This leaves open the possibility that the customer visited both locations multiple times.

To meet the condition as stated, you need to know that some visit to Santa Clara was later than some visit to Milpitas (at least that is how I interpret the question). Well, that is true if the *lastest* visit to Santa Clara was after the *earliest* visit to Milpitas.
```
SELECT DISTINCT Customer_ID
FROM table t1
JOIN table t2 USING (Customer_ID)
WHERE t1.Location = 'Santa Clara'
  AND t2.Location = 'Milpitas'
  AND t1.Store_Entry > t2.Store_Entry

```