Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create table from SELECT statement in oracle 11g [duplicate]

I want to CREATE table from another table I tried below code

CREATE TABLE AS tbl_01
As
SELECT a.col1 c1, a.col2 c2, MAX(a.col3 c3)
FROM tbl a
WHERE flag= 2
GROUP BY col1, col2

This query run, but When I am going to expand column in datatabse explorer it gives error Conversion from type DBNULL to type Integer is not valid

like image 586
dwan Avatar asked Jan 08 '23 04:01

dwan


1 Answers

Put alias outside braces in max function and try. Also you use as twice. COrrected that.

CREATE TABLE tbl_01
As
SELECT a.col1 c1, a.col2 c2, MAX(a.col3) c3
FROM tbl a
WHERE flag= 2
GROUP BY col1, col2
like image 132
Utsav Avatar answered Feb 08 '23 16:02

Utsav