Question: I have a SQL query which is returning output; I need to get substring with last occurrence, I am confused and not able to find out how to do that:

```
SELECT
    spsetuppath,
    SUBSTRING(spsetuppath, 0, (LEN(spsetuppath) - CHARINDEX('\', RTRIM(LTRIM(REVERSE(spsetuppath))))) + 1)
FROM
    UMRdb..sql_spversion 
WHERE
    bitversion = '64' 
    AND productversion = ' 10.50.2500.0'

```

Output of this command is as follows

[![enter image description here](https://i.stack.imgur.com/oieWG.png)](https://i.stack.imgur.com/oieWG.png)

For the last column, I need the path before exe and I need only exe file name - how to do that?

So output I am expecting should look like this 

```
SQLServer2008R2SP1-KB2528583-x64-ENU.exe

```

Answer: 
You can use [number\_format():](http://php.net/number_format)

```
return number_format((float)$number, 2, '.', '');

```

Example:

```
$foo = "105";
echo number_format((float)$foo, 2, '.', '');  // Outputs -> 105.00

```
In PHP, you need to use [`number_format()`](http://php.net/manual/en/function.number-format.php) function:

```
number_format($num,2);
echo number_format(11,2); // 11.00

```

Numbers are formatted with decimals. In the above example, second parameter defines how many values you want post the decimal.