title: Get day name based on custome ID of bigint[] datatype
body: <p>I want to display Day name based on ID which is in bigint[] in the table as shown below:</p>
  <p>Table:</p>
  <pre><code>create table tbl_days
  (
  day_ids bigint[]
  );
  </code></pre>
  <p>Records:</p>
  <pre><code>insert into tbl_days values('{1,2}');
  insert into tbl_days values('{1,2,3}');
  insert into tbl_days values('{1,4}');
  insert into tbl_days values('{4,7}');
  insert into tbl_days values('{1,2,3,4,5,6,7}');
  insert into tbl_days values('{2,4,7}');
  </code></pre>
  <p>Would like to display day name for:</p>
  <p>1 for Monday
  2 for Tuesday
  .
  ..
  7 for Sunday.</p>
  <p>Query 1: Using <code>replace()</code>, which is taking 3 more seconds to get the main query result.</p>
  <pre><code>select replace(replace(replace(replace(replace(replace(replace(day_ids::varchar,'1','Monday'),'2','Tuesday'),'3','Wednesday'),'4','Thursday'),'5','Friday'),'6','Saturday'),'7','Sunday') 
  from tbl_days;
  </code></pre>
  <p>Query 2: Using <code>string_agg()</code>, here problem with an order.</p>
  <p>Step 1: Add days into temp table</p>
  <pre><code>create temp table temp_days
  (
  id int,
  days varchar
  );
  
  insert into temp_days values(1,'Monday'),(2,'Tuesday'),(3,'Wednesday'),(4,'Thursday'),(5,'Friday'),(6,'Saturday'),(7,'Sunday');
  </code></pre>
  <p>Step 2: Join with main table</p>
  <pre><code>select d.day_ids,string_agg(distinct t.days,',') 
  from tbl_days d 
  inner join temp_days t on t.id = any(d.day_ids)
  group by d.day_ids
  </code></pre>