Skip to content

Convert an array to a string, find the difference set of two arrays, and find the maximum and minimum values in an array

Use the array_join function to concatenate elements in an array into a string with hyphens (-). Use the array_except function to calculate the difference set of two arrays. Use the array_max function to find the maximum value in an array. Use the array_min function to find the minimum value in an array.

SQL
* |
SELECT
  array_join(ARRAY [1, 2, 3,3,4,5,2,3], '-', 'null') as string,
  array_except(ARRAY [1,2,3,4,5], ARRAY [1,3,5,7]) as "Calculate the difference set of two arrays",
  array_max(ARRAY [1,2,3,4,5]) as "Find the maximum value in an array",
  array_min(ARRAY [1,2,2,34,5,6,1]) as "Find the minimum value in an array"