Re: [GENERAL] json aggregation question

2017-02-28 Thread Yasin Sari
Hi Chris, Maybe there is an another better solution; 1. sending values into jsonb_array_elements to getting elements (lateral join) 2. distinct to eliminate duplicates 3. regexp_replace to remove malformed Array literals 4. Casting into text array SELECT count(distinct tags ), string_to_array(r

Re: [GENERAL] count case when - PG 9.2

2017-03-10 Thread Yasin Sari
if you want see account_status and the count()- try this: SELECT CASE WHEN AND c.regdate > EXTRACT(epoch FROM (now() - INTERVAL '14 day')) THEN 'trial' WHEN last_pay > EXTRACT(epoch FROM (now() - INTERVAL '37 day')) THEN 'paying' END as account_status,

Re: [GENERAL] UPDATE ... ON CONFLICT DO NOTHING

2017-03-15 Thread Yasin Sari
Have you tried with inner block and do nothing on exception; BEGIN .. BEGIN UPDATE words_social SET uid = out_uid WHERE uid = ANY(_uids); EXCEPTION WHEN OTHERS THEN --do nothing or write NULL means do nothing