I have created a query with two joined tables and I want to return median from one column as a result.
Query looks like this:
select table1.column1, count(distinct(table2.column2))
from table1 left join
table2 on table1.column1 = table2.column4
where column3 = 1
group by table1.column1
And results looks like this(there is more lines ofc):
| column1 | column2 |
+------------+---------+
| 111 | 4 |
| 222 | 5 |
| 333 | 5 |
| 444 | 5 |
And I want to pull out median from column2 results.
Is there any way to do it without major modifications in this query?