Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.56 KB | None | 0 0
  1.   CREATE OR REPLACE FUNCTION avgState2 ( state map<BIGINT,int>) CALLED ON NULL INPUT RETURNS map<text, int> LANGUAGE java AS
  2.   'int total = 0;int cont = 0; int max = Integer.MIN_VALUE; int min = Integer.MAX_VALUE; for(Long key : state.keySet()){int valor = state.get(key);  if(min > valor) min = ; if(max < valor) max = valor;  total += valor;cont ++;} Map<String, Integer> solucion = new HashMap<String, Integer>(); solucion.put("promedio", total/cont );solucion.put("cantidad", cont); solucion.put("maximo", max); solucion.put("minimo", min); return solucion;';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement