How to translate following python expression to postgesql?
>>> ','.join([30 for x in range(3)]) 30,30,30
I have table with colums:
id | entry | type | size 1 10 0 10 2 20 0 10 3 30 1 10 4 30 2 15
I want to query it like this:
SELECT id, CASE WHEN type = 1 THEN --For entry 30 and size 10 (300) - get 150,90,60 WHEN type = 2 THEN --For entry 10 and size 15 (150) - get 30,30,30,30,30 ELSE entry*size END FROM table;
UPD Expected result:
id | prize_pool 1 | 100 2 | 200 3 | 150,90,60 4 | 30,30,30,30,30
UPD2 Equivalent function in python:
def prize_pool(entry,type,size): prize = entry*size if type == 0: return [prize] if type == 1: return [prize * x for x in [0.5,0.3,0.2]] if type == 2: return [prize/int(size/3) for x in range(int(size/3))]
prize_pool(entry,type,size)
function in python.