jeudi 30 décembre 2021

Is it possible to get a random value within a group in a group by query?

I would like to get random values within a group-by query, something like this:

SELECT city
  , SOME_RANDOMIZER_FUNC(latitude) as "RANDOM_LATITUDE_IN_CITY"
  , SOME_RANDOMIZER_FUNC(longitude) AS "RANDOM_LONGITUDE_IN_CITY"
FROM some_table
GROUP BY city

Where the function SOME_RANDOMIZER_FUNC returns a random value within the group.




Aucun commentaire:

Enregistrer un commentaire