```
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
DECLARE M INT;
SET M=N;
RETURN (
**SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT M-1,1**
);
END
```

this query gives exception when M=0 as it becomes -1

however when I write it like

```
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
DECLARE M INT;
SET M=N-1;
RETURN (
**SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT M,1**
);
END
```

Please explain the difference between the two statements