Question: Computed properties on ember views have the form

```
myComputedProperty: function() {
    return doSomething();
}.property()

```

However, when I write this in coffescript as 

```
myComputedProperty: ->
    doSomething()
.property()

```

I get an error like "Parse error on line 5: Unexpected '.'". Am I doing something wrong, or is this a quirk of the interpreter I'm using (Mindscape VS plugin)?

Answer: 
This will work providing the values in LOCATION and CATEGORY are constant:

```
select empnum
       , empname
       , sum(case when location='BLDG A' and category = 1 then count else 0 end) sum_a1 
       , sum(case when location='BLDG A' and category = 2 then count else 0 end) sum_a2
       , sum(case when location='BLDG A' and category = 3 then count else 0 end) sum_a3
       , sum(case when location='BLDG B' and category = 1 then count else 0 end) sum_b1
       , sum(case when location='BLDG B' and category = 2 then count else 0 end) sum_b2
       , sum(case when location='BLDG B' and category = 3 then count else 0 end) sum_b3
from your_table
group by empnum
       , empname

```

If the values are not known or not stable when you run the query you will need to use dynamic SQL.

---

Note that if you are on 11g you should employ [A B Cade's PIVOT solution](https://stackoverflow.com/a/13082873/146325), which is more elegant.
The other answers will work great if you have a known number of values to transform into columns. But if you have an unknown number, then you can use dynamic sql to generate the results. 

You would create the following procedure:

```
CREATE OR REPLACE procedure test_dynamic_pivot(p_cursor in out sys_refcursor)
as
    sql_query varchar2(1000) := 'select empnum, empname';

    begin
        for x in (select distinct location, category from yourtable order by 1)
        loop
            sql_query := sql_query ||
              ' , sum(case when location = '''||x.location||''' and category='||x.category||' then cnt else 0 end) as sum_'||substr(x.location, -1, 1)||x.category;

                dbms_output.put_line(sql_query);
        end loop;

        sql_query := sql_query || ' from yourtable group by empnum, empname';

        open p_cursor for sql_query;
    end;
/

```

And then to execute it:

```
variable x refcursor
exec test_dynamic_pivot(:x)
print x

```

The result is the same as the hard-coded version:

```
| EMPNUM |   EMPNAME | SUM_A1 | SUM_A2 | SUM_A3 | SUM_B1 | SUM_B2 | SUM_B3 |
----------------------------------------------------------------------------
|    234 | EMILY DOE |      1 |      2 |      4 |      0 |     12 |      3 |
|    123 |  JOHN DOE |     11 |      4 |      7 |      1 |      3 |      0 |

```