Dab tsi yog qhov kev sib sau ua ke hauv SQL?
Dab tsi yog qhov kev sib sau ua ke hauv SQL?

Video: Dab tsi yog qhov kev sib sau ua ke hauv SQL?

Video: Dab tsi yog qhov kev sib sau ua ke hauv SQL?
Video: Wb Tsis Sib Tau los Yog Qhov zoo By Nkauj noog hawj 2024, Kaum ib hlis
Anonim

Aggregate functions hauv SQL . Hauv kev tswj hwm database ib aggregate muaj nuj nqi yog a muaj nuj nqi qhov twg qhov tseem ceeb ntawm ntau kab yog pawg ua ke raws li cov tswv yim ntawm qee cov qauv los tsim ib qho txiaj ntsig ntawm ntau lub ntsiab lus tseem ceeb. Ntau yam Aggregate Functions.

Sib piv, dab tsi yog qhov kev ua haujlwm sib sau ua ke hauv SQL nrog piv txwv?

Ib qho kev sib sau ua ke ua ib qho kev suav ntawm ib qho txiaj ntsig, thiab xa rov qab ib zaug tus nqi . Tsuas yog rau COUNT , aggregate functions ignore null values. Kev sib sau ua haujlwm feem ntau siv nrog GROUP BY clause ntawm SELECT nqe lus.

Ib sab saum toj, pes tsawg lub luag haujlwm muaj nyob rau hauv SQL? MySQL txhawb nqa tag nrho tsib (5) ISO tus qauv aggregate functions COUNT, SUM, AVG, MIN thiab MAX.

Kuj paub, qhov twg ntawm cov kev xaiv hauv qab no yog kev sib sau ua haujlwm hauv SQL?

Cov hauv qab no yog cov feem ntau siv SQL aggregate functions: AVG () - rov qab qhov nruab nrab ntawm ib txheej. COUNT () - xa rov qab tus naj npawb ntawm cov khoom hauv ib txheej. MAX() – rov qab qhov siab tshaj plaws tus nqi hauv ib txheej.

Lub luag haujlwm tag nrho nyob qhov twg?

Yog tias SELECT nqe lus suav nrog WHERE clause, tab sis tsis yog GROUP BY clause, ib qho aggregate muaj nuj nqi tsim ib qho nqi rau cov kab sib txuas uas qhov WHERE clause qhia. Thaum twg ib aggregate muaj nuj nqi yog siv nyob rau hauv SELECT nqe lus uas tsis suav nrog GROUP BY clause, nws tsim ib qho nqi.

Pom zoo: