title: create simple select with basic inner join using function
body: <p>I'm new to postgresql and i got basic knowledge of join statements now i'm trying to create a function out of this</p>
  <pre><code>select r.studid,r.subjcode,r.section,s.subjdesc,r.sy,r.sem,r.grade,r.gcompl
  from registration r
  inner join subject s ON r.subjcode = s.subjcode
  where studid = '2020-2001' AND r.grade = 'INC' AND COALESCE(gcompl, '') = ''
  ORDER BY studid DESC;
  </code></pre>
  <p>I'm currently using postgresql v9.5 w/ pgadmin III
  edit i got it working</p>
  <pre><code>CREATE OR REPLACE FUNCTION srgb.viewincgrade(p_studid char)
  RETURNS TABLE (studid char,subjcode char,section char ,subjdesc 
  varchar,sy char,sem char,grade varchar,gcompl varchar)
  AS
  $$
  BEGIN
  return query
  select 
  r.studid,r.subjcode,r.section,s.subjdesc,r.sy,r.sem,r.grade,r.gcompl
  from registration r
  INNER JOIN subject s ON r.subjcode = s.subjcode
  where r.studid = p_studid AND r.grade = 'INC' AND COALESCE(r.gcompl, 
  '') = ''
  ORDER BY studid DESC;
  END
  $$
  LANGUAGE plpgsql;
  </code></pre>