title: Azure Stream Analytics Pivoting Rows To Columns
body: <p>I have a data like;</p>
  
  <pre><code>        [
          {"deviceid":"d1","parameter"="p1" value="1" timestamp="2018-03-22T12:33:00"},
          {"deviceid":"d1","parameter"="p2" value="2" timestamp="2018-03-22T12:34:00"},
          {"deviceid":"d1","parameter"="p2" value="3" timestamp="2018-03-22T12:35:00"},
          {"deviceid":"d2","parameter"="p1" value="4" timestamp="2018-03-22T12:36:00"},
          {"deviceid":"d2","parameter"="p2" value="5" timestamp="2018-03-22T12:37:00"},
          {"deviceid":"d2","parameter"="p2" value="6" timestamp="2018-03-22T12:38:00"},
          {"deviceid":"d2","parameter"="p1" value="7" timestamp="2018-03-22T12:43:00"},
          {"deviceid":"d2","parameter"="p1" value="8" timestamp="2018-03-22T12:44:00"},
          {"deviceid":"d2","parameter"="p2" value="9" timestamp="2018-03-22T12:45:00"},
          {"deviceid":"d1","parameter"="p1" value="10" timestamp="2018-03-22T12:46:00"},
          {"deviceid":"d1","parameter"="p1" value="11" timestamp="2018-03-22T12:47:00"},
          {"deviceid":"d1","parameter"="p2" value="12" timestamp="2018-03-22T12:49:00"}
          ]
  </code></pre>
  
  <p>I want to pivot that parameter values(for every 10 minutes window) and display last recieved value of each parameter for each deviceid  and like this  <strong>edit*(Parameters will be dynamic not just p1 and p2)</strong>;</p>
  
  <pre><code>------------------------------------------------------------
  | deviceid|     windowtime       |     p1    |     p2      |
  ------------------------------------------------------------
  | d1      | 2018-03-22 12:40     |     1     |      3      |
  ------------------------------------------------------------
  | d2      | 2018-03-22 12:40     |     4     |      6      | 
  ------------------------------------------------------------
  | d2      | 2018-03-22 12:50     |     8     |      9      |
  ------------------------------------------------------------
  | d1      | 2018-03-22 12:50     |     11    |     12      |
  ------------------------------------------------------------
  </code></pre>
  
  <p>Thank You.</p>