Question: I have googled on how to write a fixed length loop in Python but haven't found anything, so I ask here:

```
    for i in range(0, 25):
        index = int(random.uniform(0, len(characters)))
        code += characters[index]
    return code

```

As you see I don't need `i`. How can I rewrite this to be a fixed length loop where I don't have to define `i`?

Answer: 
For getting just maximum date for user, you can use this one -

```
SELECT
  u.id,
  u.name,
  MAX(d.date) date
FROM user u
  LEFT JOIN date d
    ON u.id = d.user_id
GROUP BY u.id

```

---

```
1   name 1  15-Aug-18
2   name 2  14-Aug-18
3   name 3  (null)

```
You can use `MAX` 

```
SELECT u.UserID, MAX(d.date) date, u.name
FROM User u
left join Date d on u.id = d.id 

```