Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Temporary work tables (a beginner's question)
Hi,
We're doing an evaluation of Oracle 7.3 against SQL Server and Sybase, and are running into a snag. The other two let us form a select statement and store the results in a temporary table, e.g.
SELECT STATE, CITY, 1 AS COUNT1, 0 AS COUNT2
INTO #COUNT1 FROM HOMETEST WHERE AGE > 21
and
SELECT STATE, CITY, 0 AS COUNT1, 1 AS COUNT2
INTO #COUNT2 FROM HOMETEST WHERE INCOME > 50000
and then UNION the resulting tables giving us counts within cities for both age groups and income
SELECT state, CITY, SUM(COUNT1) SUM1, SUM(COUNT2) SUM2
INTO #COUNT4 FROM #COUNT1 GROUP BY state, CITY
FROM #COUNT2 GROUP BY state, CITY
Temporary table #COUNT4 will have everything we need for reporting.
Oracle does not include the INTO sub-clause in its SELECT statement.
How do we accomplish this directly in Oracle. I know we can use the "CREATE TABLE AS subquery" command, but then we have to do extra management on our tablespaces.
I guess the real question we're asking is if there is any provision for work files within Oracle's design.
Thanks in advance.
Dave Received on Wed Jul 02 1997 - 00:00:00 CDT