The WITH that I am thinking about, lets you define and reuse queries which are executed once. For example:
WITH
MySummary AS (*SELECT b.dept_name, Sum(Salary) AS total_sal FROM emp a join dept b on (a.dept_id = b.dept_id) GROUP BY b.dept_name*)
  SELECT dept_name, total_sal //FROM MySummary
  WHERE total_sal > (
                     SELECT SUM (total_sal) * 1/12
                     FROM MySummary)
  ORDER BY total_sal

You can introduce multiple "aliases" and use them within any subsequent queries.

WITH alias1 as (...)
  alias2 as (...)
  alias3 as (...)
SELECT ....

Thanks,


Edwin Ramirez wrote:
> Hello,
> > What is the status of supporting the "WITH" keyword?

I see these TODO items:

        * Add SQL99 WITH clause to SELECT
        * Add SQL:2003 WITH RECURSIVE (hierarchical) queries to SELECT

Are they the same item?


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

               http://www.postgresql.org/about/donate

Reply via email to