ORACLE—008:分類統計,oracle008分類

來源:互聯網
上載者:User

ORACLE—008:分類統計,oracle008分類

分類統計使用比較多,一般用於統計某項的個數或某項下的項數有多少。

簡單的,比如一張表tab_test

tab_test記錄

id

co

name

job

1

IBM

JACK

PM

2

Google

TOM

PM

3

IBM

JIM

PM

想統計這樣的結果:

co:人數。

sql如下:

select distinct t.co,count(t.name)from tab_test tgroup by t.co;

結果

co       NAMEIBM     2Google 1

tab_test也可以是一個子查詢。

這樣一個簡單的查詢就可以做一個統計查詢。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.