【正文】
的最小值 sum(distinct 字段名 ) 求和字段值 注: distinct 限制重復(fù)值 分組統(tǒng)計(jì) ? 格式: select 字段名,聚合函數(shù)(字段名) from 表名 [where 條件 ] group by [all] 字段名 [,字段名 ] [with cube|rollup] having 條件 注 : all 忽略 where 條件,但不滿足條件行不計(jì)算 having 條件 在分組結(jié)果中進(jìn)行篩選 with cube 把 group by 后的每一個(gè)子段匯總計(jì)算 with rollup 把 group by 后的第一個(gè)子段匯總計(jì)算 例:按圖書(shū)類(lèi)別分組統(tǒng)計(jì)圖書(shū)的平均價(jià)格 分組查詢 例: Select stor_id,title_id,sum(qty) From sales Group by stor_id,title_id With cube Select stor_id,title_id,sum(qty) From sales Group by stor_id,title_id With rollup 概要檢索 例:統(tǒng)計(jì)出所有書(shū)的價(jià)格和總的預(yù)付款項(xiàng) ?格式: select [字段列表 ] from 表名 order by 字段名 pute 聚合函數(shù)(字段名) by[字段名 ] 注: pute聚合函數(shù)計(jì)算的字段必須出現(xiàn)在字段列表中 可同時(shí)觀察查詢所得的各列數(shù)據(jù)的細(xì)節(jié)以及統(tǒng)計(jì)各列數(shù)據(jù)的產(chǎn)生的總和