lundi 20 avril 2020

Postgre SQL min/max inside THEN clause

Here is my code:

INSERT INTO salaries (num)
SELECT
CASE random()<0.5 WHEN true THEN min(8+floor(random()*4),10))
WHEN false THEN max(8-floor(random()*4),1)) END AS num
FROM generate_series(1,1) as seq(my_id);

returns this error:

LINE 3: CASE random() < 0.5 WHEN true THEN (SELECT min(8+floor(rando...
                                                   ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Could you give me any hint or what am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire