Wednesday, 15 May 2013

How to calculate median of a numeric sequence in Google BigQuery efficiently? -


I need to calculate the value of a numerical sequence in Google BigQuery efficiently Is it possible?

Yes, it is possible with window function.

Returns the values ​​that are based on linear interpolation between the values ​​of the group, according to order according to order them.

should be between 0 and 1.

This window function is required Order in Order Clause.

Then an example query will be (max ()) only to work in the group, but it should not be used as a mathematical argument, (do not confuse you )

  from the settlement room, Max (average) (Select Room, Centi_sank (0.5) over (temperature by temperature in room temperature) from middle (selection 1 AS room, 11AS temperature), (1 as selection chamber, 12 AS temperature), (1 select AS room, 14AS temperature), (1 AS room, AS temperature Select as 1), (SELECT 1 AS room, 13 AS temperature), (Selection 2 AS room, 20 AS temperature), (Selection 2 AS room, 21 AS temperature), (SELECT 2 AS cell, 2 9 AS temperature), (SELECT 3 AS cell, 30 AS temperature)) Rooms by group  

This return:

  + ------ + ------------- + | Rooms | Temperature | + ------ + ------------- + | 1 | 13. | 2 | 21 | | 3 | 30 | + ------ + ------------- +  

No comments:

Post a Comment