How to select standard deviation within a row? (in SQL - or R :)

前端 未结 4 1241
时光取名叫无心
时光取名叫无心 2020-12-21 04:41

I wonder whether there is a way to select the standard deviation from several integer fields in MySQL within the same row. Obviously, if I use



        
4条回答
  •  [愿得一人]
    2020-12-21 05:12

    Have you tried using UNION to effectively put all your column values into separate rows? Something like this, maybe:

    SELECT STDDEV(allcols)
    FROM (
        SELECT col1 FROM table WHERE id=requiredID
        UNION
        SELECT col2 FROM table WHERE id=requiredID
        UNION
        SELECT col3 FROM table WHERE id=requiredID
        UNION
        SELECT col4 FROM table WHERE id=requiredID
        UNION
        SELECT col5 FROM table WHERE id=requiredID
    )
    

提交回复
热议问题