mercredi 8 janvier 2020

Median value in mysql server

The code below describes a part of mysql database table (testtable):

    A        B         C           ts
_________ _________ _______ ___________________
0.0688375 0.0049353 4.514   2020-01-01 00:00:01
0.059088  0.0538399 4.46694 2020-01-01 00:00:02
0.0368142 0.0379165 4.58889 2020-01-01 00:00:03
0.0797866 0.0296956 4.48441 2020-01-01 00:00:04
0.0126968 0.0477202 4.36262 2020-01-01 00:00:05
0.133335  0.0296263 4.88002 2020-01-01 00:00:06
0.124702  0.118684  4.89991 2020-01-01 00:00:07
0.188764  0.0674096 4.67817 2020-01-01 00:00:08
0.249208  0.0457974 4.90125 2020-01-01 00:00:09
0.236395  0.0282597 4.72523 2020-01-01 00:00:10
0.0841084 0.098171  4.85385 2020-01-01 00:00:11
0.0129359 0.104634  4.83282 2020-01-01 00:00:12
0.106398  0.029276  4.67046 2020-01-01 00:00:13
0.0177838 0.112869  4.88509 2020-01-01 00:00:14
0.161959  0.102362  4.93979 2020-01-01 00:00:15
0.107356  0.0416632 4.79583 2020-01-01 00:00:16
0.0636094 0.0636448 4.71631 2020-01-01 00:00:17
0.0381167 0.0879146 4.87459 2020-01-01 00:00:18
0.157102  0.144645  5.12384 2020-01-01 00:00:19
0.243964  0.109178  5.19458 2020-01-01 00:00:20
0.128648  0.0972374 5.22485 2020-01-01 00:00:21
0.101606  0.0945907 5.03022 2020-01-01 00:00:22

I need to check what numbers of each column are above the median of each column. after the check above I need to print out the ts that all of the 3 column numbers are above the median

There is a way to check median for each column (A,B,C) and make an if statement that print out ts when the 3 numbers in the row are above the median?

Or if it is more simple, how to write it in python?

Aucun commentaire:

Enregistrer un commentaire