sql 1 整合資料

2021-08-19 21:53:24 字數 1330 閱讀 1530

1.讀表

create table if not exists part1 as select * from odps_tc_257100_f673506e024.meinian_round2_data_part1;

create table if not exists part2 as select * from odps_tc_257100_f673506e024.meinian_round2_data_part2;

create table if not exists snp as select * from odps_tc_257100_f673506e024.meinian_round2_snp;

2.

select cast(user_id as double) as new_id from user;

select cast('2015-10-01 00:00:00' as datetime) as new_date from user;

-輸入資料已自動對映成t1~t4,使用方式如:select * from $

--使用者也可以直接輸入odps表使用。

--本元件支援odps sql的所有語法,最後一條sql必須為select語句,查詢結果作為本元件的輸出資料

select age,

(case *** when 'male' then 1 else 0 end) as ***,

(case cp when 'angina' then 0 when 'notang' then 1 else 2 end) as cp,

trestbps,

chol,

(case fbs when 'true' then 1 else 0 end) as fbs,

(case restecg when 'norm' then 0 when 'abn' then 1 else 2 end) as restecg,

thalach,

(case exang when 'true' then 1 else 0 end) as exang,

oldpeak,

(case slop when 'up' then 0 when 'flat' then 1 else 2 end) as slop,

ca,(case thal when 'norm' then 0 when 'fix' then 1 else 2 end) as thal,

(case status when 'sick' then 1 else 0 end) as ifhealth

from $;

SQL 1 資料庫概念

catalog 分類 又叫資料庫database 表空間tablespace 主鍵 primarykey 主鍵就是資料行的唯一標識。不會重複的列才能當主鍵。乙個表可以沒有主鍵,但是會非常難以處理,因此沒有特殊理由表都要設定主鍵 主鍵有兩種選用策略 業務主鍵和邏輯主鍵。業務主鍵是使用有業務意義的字段做...

重塑與整合資料集 reshape包

重塑資料時,通過修改資料的結構 行和列 來決定資料的組織方式。整合資料時,往往將多組觀測替換為這些觀測計算的描述性統計量。整合函式的語法 aggregate x,by,fun x是待摺疊的資料的物件,by是乙個變數名組成的列表,這些變數將被去掉以形成新的觀測 fun是用來計算描述性統計量的標量函式,...

深入淺出SQL(1)

建立資料庫 create database gregs list 告訴rdbms使用哪個資料庫 use gregs list 建立簡單的表 create table doughnut list dougnut name varchar 10 dougnut type varchar 6 常用資料型別...