sql指令碼練習01

2021-10-01 22:24:44 字數 2203 閱讀 8169

原來在聚鯊的練習題(實際操作)(已經理解了)

主要需要理解的部分是:inner join 樂翻天join right join 的區別。二者之間的區別是以誰為主要的表,主要顯示誰的問題。

其次需要理解的是 select * from a inner join b on a.khdm = b.khdm inner join c on c.khdm = a.khdm 只要是可以繼續下去的就可以 不斷的寫下去

第三個需要注意的是:我的可以在我想加入的渠道中顯示任何我已經有的知識。如「北京」 tb

select

*from

(select

distinct a.khdm, a.zfl

from hqods.yg_res_ddyjb a

-- left join hqods.yg_ref_good_info b

-- on a.spbh = b.spbh

where a.zfl in

('紀念收藏品'

)and a.khdj in

('紫金會員'

,'**會員'

,'普通會員'

,'白金會員'

,'鑽石會員'

)--group by khdm, b.zfl

) m inner

join

(select cust_id khdm, cust_lvl_desc 會員等級, province_nm

from hqods.yg_dim_customer h

where cust_lvl_desc in

('紫金會員'

,'**會員'

,'普通會員'

,'白金會員'

,'鑽石會員'

)) x

on x.khdm = m.khdm

inner

join

(select e.customernumber,

u.name,

g.grpname,

e.bindstatus,

'北京' tb

from hqods.v_bf_crm_cp_customer e ---------------會員明細,繫結關係

inner

join hqods.crm_sys_user u

on e.assignedusr = u.usrid

inner

join hqods.crm_sys_uglink ug

on ug.usrid = u.usrid

inner

join hqods.crm_sys_grp g

on g.grpid = ug.grpid

inner

join

(select g.grpid,

g.grpname,

g.parentid,

rownum rn

from hqods.crm_sys_grp g

where g.

type

='1'

start

with g.grpid =

'mgrlv'

connect

by prior g.grpid = g.parentid) t1

on g.grpid = t1.grpid

inner

join

(select g.grpid,

g.grpname,

g.parentid,

rownum rn

from hqods.crm_sys_grp g

where g.

type

='1'

start

with g.grpid =

'agentgrp'

connect

by prior g.grpid = g.parentid) t

on g.grpid = t.grpid

where e.bindstatus =

1) h

--left join (select grpname 組, td from hqods.v_yg_dim_dsjzb) e

-- on h.grpname = e.組

-- group by customernumber, name, grpname, td

-- ) f

on m.khdm = h.customernumber

習題練習01

給定乙個整數陣列 nums 和乙個目標值 target,請你在該陣列中找出和為目標值的那 兩個 整數,並返回他們的陣列下標。你可以假設每種輸入只會對應乙個答案。但是,陣列中同乙個元素不能使用兩遍。示例 給定 nums 2,7,11,15 target 9 因為 nums 0 nums 1 2 7 9...

Python指令碼練習

購物車 usr bin env python coding utf 8 account input 請輸入您的帳戶餘額 menu list 商品列表 buy cost 0 print list for k,v in enumerate menu print k,v,menu v c y while ...

shell指令碼練習

顯示系統資訊 bin bash descrition show system information echo os version is cat etc centos release echo kernel version is uname r echo cpu type lscpu grep m...