[英]Create table with aggregate data from another table, using SQL
I am trying to create the tableau_table_1 table from the aggregated data of the covid_deaths table.我正在尝试根据 covid_deaths 表的聚合数据创建 tableau_table_1 表。
Here is my query...这是我的查询...
CREATE TABLE tableau_table_1 AS
SELECT
SUM(new_cases) AS total_cases,
SUM(cast(new_deaths as int)) AS total_deaths,
SUM(cast(new_deaths as int))/SUM(New_Cases)*100 AS death_percentage
FROM
covid_data..covid_deaths
WHERE continent IS NOT NULL
-- Group By date order by 1,2
The error that I am showing is...我显示的错误是......
Incorrect syntax near the keyword 'from'
You could try SELECT INTO Statement你可以试试 SELECT INTO Statement
SELECT * INTO tableau_table_1
FROM (
SELECT
SUM(new_cases) AS total_cases,
SUM(cast(new_deaths AS int)) AS total_deaths,
SUM(cast(new_deaths AS int))/SUM(New_Cases)*100 AS death_percentage
FROM
covid_data..covid_deaths
WHERE continent IS NOT NULL) AS aggregated_data;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.