title: PostgreSQL - Function to return multiple columns
body: <p>Here's a function that provides a result of 2 columns.</p>
  
  <p>In this function there's a <code>Loop</code> been used to return the result.</p>
  
  <p><strong>Function :</strong></p>
  
  <pre>
  Create Type Repeat_rs as (
  label text,
  count bigint
  )
  
  CREATE OR REPLACE FUNCTION Repeat(fromDate date,toDate date)
  returns SETOF  Repeat_rs
  AS 
  $$
  Declare someVariableName Repeat_rs;
  BEGIN
      For someVariableName in (
          SELECT label, count(*) AS Cnt from test where date between fromDate and toDate group by circle
      ) Loop
      Return Next someVariableName;
      End Loop;
      Return;
  END;
  $$
  LANGUAGE plpgsql;
  </pre>
  
  <p>Is there any possibilities of returning the rows without using loop?</p>
  
  <p>If so please do share me on how we can do it.</p>
  
  <p>And will I be able to write a function to insert records on to a table without using loop?</p>
  
  <p>Help me out to solve this query.</p>
  
  <p>Thanks in advance.</p>