Re: Extract especific text from a sql statement - Mailing list pgsql-general

From Melvin Davidson
Subject Re: Extract especific text from a sql statement
Date
Msg-id CANu8FixAUS_etohM+OBXWB0VPrMQp1KNVkogFk_2rdwnRcNaPA@mail.gmail.com
Whole thread Raw
In response to Re: Extract especific text from a sql statement  (David G Johnston <david.g.johnston@gmail.com>)
Responses Re: Extract especific text from a sql statement  (David G Johnston <david.g.johnston@gmail.com>)
List pgsql-general
You already have most of the result columns, so the following should do it.

 SELECT pc.cod,
        pc.val,
        pi.qtd,
        COALESCE(pc.name, 'empty') AS name,
        lower(coalesce(pc.email, 'empty')) as email,
        status,
        c1.relname,
        c2.relname,
        pc.startdate
 FROM pc
 INNER JOIN pi on (pc.cod = pi.cod)
  JOIN pg_class c1 ON (c1.relname = 'pc' AND c1.relkind = 'r'
  JOIN pg_class c2 ON (c2.relname = 'pi' AND c2.relkind = 'r'
 WHERE pc.startdate > CURRENT_DATE
 order by 1 desc;

Learn the catalogs and you will learn to be a good dba.

Melvin Davidson

pgsql-general by date:

Previous
From: David G Johnston
Date:
Subject: Re: Is there a way to get both the plan and the results?
Next
From: David G Johnston
Date:
Subject: Re: Extract especific text from a sql statement