Skip site navigation (1) Skip section navigation (2)

Re: Controlling order of evaluation?

From: Russell Smith <mr-russ(at)pws(dot)com(dot)au>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Controlling order of evaluation?
Date: 2004-09-29 01:13:12
Message-ID: 200409291113.12954.mr-russ@pws.com.au (view raw or flat)
Thread:
Lists: pgsql-general
On Wed, 29 Sep 2004 08:16 am, Jerry LeVan wrote:
> I have an srf sql function "annual_report(<year>)" that
> as 14 columns, a category, 12 month numeric columns,  and a total 
> numeric column.
> 
> The function finds monthly totals for each category (which is the 
> target of "order by")
> and the grand total for the specified year.
> 
> I have another sql function annual_profit_loss(<year>) that summarizes 
> the total
> for each month and the grand total for each year. ( There is a text 
> column that
> serves a label.) It generates a summary for the annual_report function 
> in essence.
> 
> I have hoped that
> 
> select * from annual_report(2003)
> union
> select * from annual_profit_loss(2003)
Order by title_column = 'Grand Total', month

that will put all rows not containing grand total at the top, sorted by month.
Then grand total's sorted by month.  something like that.

>
 
> would print the last select last ;( but it inserts the last selection
> alphabetically into the rows of the annual_report depending on the label
> field... I suppose I could use a label "zzGrand Totals", but that just
> does not look right.
> 
> Is there any way I can force the last select to appear last?
> 
> Jerry
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 
> 

In response to

pgsql-general by date

Next:From: Michael FuhrDate: 2004-09-29 01:13:18
Subject: Re: Foreign key order evaluation
Previous:From: Michael FuhrDate: 2004-09-29 00:51:51
Subject: Re: Foreign key order evaluation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group