Koj puas tuaj yeem siv pab pawg tsis muaj kev sib sau?
Koj puas tuaj yeem siv pab pawg tsis muaj kev sib sau?

Video: Koj puas tuaj yeem siv pab pawg tsis muaj kev sib sau?

Video: Koj puas tuaj yeem siv pab pawg tsis muaj kev sib sau?
Video: HLUB KOJ IB LEEG TSIS MUAJ NQIS By Maiv Xis Xyooj Nkauj Tawm Tshiab Official 2022 2024, Kaum ib hlis
Anonim

Koj siv tau tus PIB YOG clause tsis muaj thov ib tag nrho muaj nuj nqi. Cov lus nug nram qab no tau txais cov ntaub ntawv los ntawm lub rooj them nyiaj thiab pab pawg qhov tshwm sim los ntawm tus neeg siv khoom id. Hauv qhov no, lub PIB Los ntawm kev ua haujlwm zoo li DISTINCT clause uas tshem tawm cov kab sib npaug ntawm qhov tshwm sim.

Tsuas yog li ntawd, peb puas tuaj yeem siv tag nrho cov haujlwm tsis muaj pab pawg los ntawm?

Yog lawm koj siv tau ib aggregate tsis muaj GROUP LOS NTAWM: SELECT SUM(col) NTAWM tbl; Koj tshem cov kab los ntawm SELECT sab hauv aggregate functions , tag nrho lwm cov kab yuav tsum muaj nyob rau hauv PIB BY clause cais los ntawm comma.

Kuj Paub, yog pab pawg los ntawm kev sib sau ua haujlwm? Cov PIB LOS NTAWM nqe lus pab pawg kab uas muaj cov txiaj ntsig zoo ib yam rau hauv cov kab lus, xws li "nrhiav tus naj npawb ntawm cov neeg siv khoom hauv txhua lub teb chaws". Cov PIB BY nqe lus feem ntau siv nrog aggregate functions (COUNT, MAX, MIN, SUM, AVG) rau pab pawg qhov tshwm sim-set los ntawm ib lossis ntau kab.

Ua ke, peb puas tuaj yeem siv pab pawg los ntawm yam tsis muaj kab lus?

Siv muaj tsis muaj pab pawg los ntawm. Cov lus nug nrog a muaj clause yuav tsum muaj ib pab pawg los ntawm lus . Yog koj omit pab pawg los ntawm, tag nrho cov kab tsis cais los ntawm qhov twg lus rov los ua ib leeg xwb pab pawg . Vim tsis muaj kev sib koom ua ke ntawm qhov twg thiab muaj clauses , lawv tsis tuaj yeem ua tus kheej ntawm ib leeg.

Peb puas tuaj yeem siv pab pawg los ntawm kev koom nrog?

Koj ua tau nug cov ntaub ntawv los ntawm ntau lub rooj siv INNER Koom clause, tiam siv tus PIB BY clause rau pab pawg kab mus rau hauv ib txheej ntawm cov kab lus xaus.

Pom zoo: