user3553846
user3553846

Reputation: 342

Create table with other table data

Following query works but i want with 2 fields

CREATE TABLE TOTAPPS (ANUM) AS SELECT a.A# FROM APPLICANT a.

This is work that

//TOTAPPS
ANUM
--------

if i want to create with 2 fields?

//Totapps
ANUM               NUMBER
---------------------------

how should i create the table? in order to get the correct out? and the NUMBER is refer to the ANUM , for example

CREATE TABLE TOTAPPS (ANUM) AS SELECT a.A# FROM APPLICANT a,
   (NUMBER) AS SELECT COUNT(*) FROM a.A#;

but it's failed to work.

Upvotes: 0

Views: 50

Answers (1)

Guneli
Guneli

Reputation: 1731

Calling a column NUMBER is not correct as it is a reserved word. Assuming from your second query that you want to add to your table distinct values of a.A# and the count of these values in the table, you should try this:

CREATE TABLE TOTAPPS (ANUM, MYNUMBER) AS 
SELECT a.A#, COUNT(a.A#) FROM APPLICANT a GROUP BY a.A#;

Upvotes: 1

Related Questions