Question: I have 2 separate columns, 'ATFTE' and 'SATFTE'. Using these two columns, I have to perform division and store the result in a separate column (say Pyramid). I am trying to use isnull function, because in many cases, the denominator is 0 and bringing it in a subquery. It shows error - 'Invalid Column name' - ATFTE and SATFTE. How can I rectify it?

```
select isnull(ATFTE/SATFTE,0) as Pyramid
from dw_UtilizationPredictionReport
where WFMGrade in (
select WFMGrade,
    case 
        when WFMGrade IN ('P/PA','PAT','A') then sum(TotalFTE)
        else 0
    END as ATFTE,
    case
        when WFMGrade IN ('SA','M','SM','AD','D','SD','AVP','VP','SVP','EVP') 
        and WFMGrade NOT IN ('Cont') then sum(TotalFTE)
        else 0
    END as SATFTE
from dw_UtilizationPredictionReport
group by (WFMGrade)
)

```

Answer: 
Currently it is assigning the last value as all parameter have same name.

You can use `[]` after variable name , it will create newcoach array with all values within it.

```
$test = "newcoach[]=6&newcoach[]=11&newcoach[]=12&newcoach[]=13&newcoach[]=14";

echo '<pre>';
parse_str($test,$result);
print_r($result);

```

O/p:

```
Array
(
    [newcoach] => Array
        (
            [0] => 6
            [1] => 11
            [2] => 12
            [3] => 13
            [4] => 14
        )

)

```
Use this function 

```
function proper_parse_str($str) {
  # result array
  $arr = array();

  # split on outer delimiter
  $pairs = explode('&', $str);

  # loop through each pair
  foreach ($pairs as $i) {
    # split into name and value
    list($name,$value) = explode('=', $i, 2);

    # if name already exists
    if( isset($arr[$name]) ) {
      # stick multiple values into an array
      if( is_array($arr[$name]) ) {
        $arr[$name][] = $value;
     }
  else {
    $arr[$name] = array($arr[$name], $value);
  }
}
# otherwise, simply stick it in a scalar
else {
  $arr[$name] = $value;
    }
  }

  # return result array
  return $arr;
}

$parsed_array = proper_parse_str($newcoach);

```