9.25

1.

因為emp_v的數(shù)據(jù)是由employees表中emp_no > 10005的數(shù)據(jù)組成,所以可以直接輸出emp_v的記錄
select *from emp_v
或者利用intersect(交集)求兩表的交集
select *from emp_v intersect select *from employees

2.

不能使用intersect關鍵字,可直接輸出emp_v,也可以用where增加條件select *from employees where emp_no > 10005

3.查找字符串'10,A,B' 中逗號','出現(xiàn)的次數(shù)cnt。

利用length求出字符串的長度,再用replace將字符串中','替換成空'',兩者長度差即為','的次數(shù)
select length('10,A,B') - length(replace('10,A,B',',',''))

4.

按照first_name的后兩位字母升序排序,需要用到substr(X,Y)截取字符串,其中X表示字符串,Y表示截取的起始位置。
select first_name from employees order by substr(first_name,-2)
其中Y<0表示從右邊數(shù)起,-1開始
select first_name from employees order by substr(first_name,length(first_name)-1)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容