單行子查詢
子查詢結(jié)果是 一個(gè)列一行記錄
select a,b,c
from table
where a >(select avg(xx) from table )
還支持這種寫(xiě)法,這種比較少見(jiàn)
select a,b,c
from table
where (a ,b)=(select xx,xxx from table where col=‘000’ )
多行子查詢
子查詢結(jié)果是 一個(gè)列多行記錄
select a,b,c
from table
where a > [ some | any | ALL ](select avg(xx) from table group by col )
單行函數(shù) VS 聚合函數(shù)
單行函數(shù) 可以嵌套 len,ROUND 等
聚合函數(shù) 不能對(duì)包含聚合或子查詢的表達(dá)式執(zhí)行聚合函數(shù)。
但 Oracle 數(shù)據(jù)庫(kù) 支持聚合函數(shù)嵌套
IN、SOME 、ANY、ALL
In
等于列表中 任意一個(gè)
where xxx in (select distinct col from t)文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-634484.html
some | any | all
some、any:需要和單行比較符一起使用,和子查詢返回的某一個(gè)值比較
ALL: 需要和單行比較符,和子查詢返回的所有值比較
some 、any 效果一樣
where xxx [>=、<=、>、<] some | any | all (select distinct col from t)文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-634484.html
到了這里,關(guān)于SQL 單行子查詢 、多行子查詢、單行函數(shù)、聚合函數(shù) IN 、ANY 、SOME 、ALL的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!