Thanks for the helpful tip!
Tim
- Original Message -
From: "Tom Lane" <[EMAIL PROTECTED]>
To: "Tim Barnard" <[EMAIL PROTECTED]>
Cc: "Jim" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 7:50 AM
Subject: Re: [G
I wrote:
> select ASMT_CODE, PASSED, TOTAL, PASSED::float4/TOTAL::float4
> from
> (select ASMT_CODE, count(*) as TOTAL from RESULTS
> group by ASMT_CODE) as tmp1
> natural join
> (select ASMT_CODE, count(*) as PASSED from RESULTS
> where STATUS='PASSED' group by ASMT_CODE) as t
"Tim Barnard" <[EMAIL PROTECTED]> writes:
> To my thinking there's got to be a better way to do this whithout so many
> temporary tables.
In 7.1 you can frequently replace temp tables with subselect-in-FROM.
Cutting-and-pasting freely from your solution:
select ASMT_CODE, PASSED, TOTAL, PASSED::
I was able to do this, but not with a simple query :-(
Here's the solution I came up with. Perhaps someone else
knows an easier way to do this?
Using your table (called 'RESULTS' in my example):
test=# select ASMT_CODE,count(*)::float4 as TOTAL into tmp1 from RESULTS
group by ASMT_CODE;
Table t