1、把兩張**的資料抽取出來放到另外一張**中
(1)pt表
role_id int
pt int
(2)season_score表
role_id int
season_score int
(3)player表
role_id int
pt int
season_score int
count int
(4)把pt表和season_score表的資料移動到player表中,並且把player表的count欄位的值設定為1
(5)sql語句如下:
replace
into
`player` (
role_id,
`pt`,
`season_score`,
`count`
) select
tmp.t1,
coalesce (tmp.t2, 0),
coalesce (tmp.t3, 0),
1from((
select
p.role_id as t1,
p.pt as t2,
s.season_score as t3
from
pt as p
left
join season_score as s on p.role_id = s.role_id
)union
(select
s.role_id as t1,
p.pt as t2,
s.season_score as t3
from
season_score as s
left
join pt as p on p.role_id = s.role_id
)) tmp;
SQL語句練習
建立一張表,記錄 呼叫員的工作流水,記錄呼叫員編號,對方號碼,通話開始時間,結束時間。建表,插資料等都自己寫出sql 要求 輸出所有資料中通話時間最長的5條記錄。輸出所有資料中撥打長途號碼 對方號碼以0開頭 的總時長 輸出本月通話時長最多的前三個呼叫員的編號 輸出本月撥打 次數最多的前三個呼叫員的編...
SQL 語句練習
mysql select from persons limit 5 oracle select from persons where rownum 5 select from persons where name like l select from persons where name not l...
sql語句練習
select instr xtr x from dual t instr,函式,返回某字元出現的位置 select instr syran ma a 1,2 from dual select to char sysdate,yyyy mm dd hh24 mi ss from dual select...