I'm trying to do this query:

```
SELECT MAX(`peg_num`)
  AS "indicator"
FROM `list`
WHERE `list_id` = 1
  AND "indicator" >= 1

```

But I'm getting the result of `NULL`. What I should be getting is `99`, as the range of `peg_num` is 00 to 99.

The value checked against "indicator" should actually be a user input, so I want it to be versatile. But, it *does* give me the correct result if I flip the equality around:

```
SELECT MAX(`peg_num`)
  AS "indicator"
FROM `list`
WHERE `list_id` = 1
  AND "indicator" <= 1

```

Why would it do this?

Edit:

As suggested, I'm using the HAVING clause... but I just ditched the alias for now anyway:

```
SELECT MAX(`peg_num`) AS "indicator"
FROM `list`
GROUP BY `list_id`
HAVING MAX(`peg_num`) <= 40

```

Still very stubborn. It gives me 99 now no matter the value in the having clause, regardless of the inequality.

Edit2:

As a clarification:

What I want to happen is the query select the largest value in the range of peg\_num, but only if it is larger than a user-given input. So, the max in this case is 99. If the user wants to select a number like 101, he/she can't because it's not in the range.