2 Replies Latest reply: Jun 5, 2014 3:19 PM by Marcio Oliveira RSS

    Maior valor baseado em outra coluna

      Como eu faço para retornar um valor baseado em outra coluna?

      Tipo, quero mostrar o cliente com maior venda

        • Re: Maior valor baseado em outra coluna
          Clever Anjos

          Verifique seu manual para a função

          firstsortedvalue ([ distinct ] expression [, sort-weight [, n ]])

          Returns the first value of expression sorted by corresponding sort-weight when expression is iterated over a number of records as defined by a group by clause. Sort-weight should return a numeric value where the lowest value will render the corresponding value of expression to be sorted first. By preceding the sort-value expression with a minus sign, the function will return the last value instead. If more than one value of expression share the same lowest sort-order, the function will return NULL. By stating an n larger than 1, the nth value in order will be returned. If the word distinct occurs before the expression, all duplicates will be disregarded.




          Load Customer,

          firstsortedvalue(PurchasedArticle, OrderDate) as FirstProductBought from abc.csv

          group by Customer;