title: median in SQLITE on group
body: <p>I have the following problem: I need the median in sqlite for groups.</p>
  
  <p>Example: I have a network with multiple start and end points and several travel distances between each of them. I now need the median of each start/end pair.</p>
  
  <p>For the following table:</p>
  
  <pre><code>    Start  | End  | Time
        A    |  B   |  5
        A    |  B   |  9
        A    |  B   |  6
        B    |  C   |  4
        B    |  C   |  8
        C    |  A   |  5
        C    |  B   |  6
  </code></pre>
  
  <p>I would like the following result:</p>
  
  <pre><code>    Start | End  | Median(Time)
        A   |  B   |   6
        B   |  C   |   6
        C   |  A   |   5
        C   |  B   |   6
  </code></pre>
  
  <p>I have seen how to compute the median here: <a href="https://stackoverflow.com/questions/15763965/how-can-i-calculate-the-median-of-values-in-sqlite">How can I calculate the median of values in SQLite?</a>, but I have no clue how to apply this on groups.</p>
  
  <p>To create the table use the following code:</p>
  
  <pre><code>CREATE TABLE "Times" ("Key" INTEGER PRIMARY KEY  AUTOINCREMENT  NOT NULL  UNIQUE , "START" TEXT, "END" TEXT, "TIME" INTEGER);
  INSERT INTO "Times" VALUES(1,'A','B',5);
  INSERT INTO "Times" VALUES(2,'A','B',9);
  INSERT INTO "Times" VALUES(3,'A','B',6);
  INSERT INTO "Times" VALUES(4,'B','C',4);
  INSERT INTO "Times" VALUES(5,'B','C',8);
  INSERT INTO "Times" VALUES(6,'C','A',5);
  INSERT INTO "Times" VALUES(7,'C','B',6);
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>