• SELECT REP_OFFICE, MIN(QUOTA), MAX(QUOTA) FROM SALESREPS GROUP BY REP_OFFICE
  • SELECT COUNT(DISTINCT CUST_NUM), CUSTOMERS FOR SALESREPS, CUST_REP FROM CUSTOMERS GROUP BY CUST_REP
  • SELECT REP, CUST, SUM(AMOUNT) FROM ORDERS GROUP BY REP, CUST
  • SELECT REP, AVG(AMOUNT) FROM ORDERS GROUP BY REP




    Download 84,3 Kb.
    bet11/18
    Sana12.01.2024
    Hajmi84,3 Kb.
    #135637
    1   ...   7   8   9   10   11   12   13   14   ...   18
    Bog'liq
    Mavzu Microsoft Access dasturida hisobotlar yaratish. Reja-fayllar.org

    SELECT REP, AVG(AMOUNT)
    FROM ORDERS
    GROUP BY REP
    REP maydoni bu holda guruhlash maydonidir, ya‘ni REP maydonning hamma
    qiymatlari guruhlarga ajratiladi va har bir guruh uchun AVG(AMOUNT) ifodasi
    hisoblanadi! YA‘ni quyidagilar bajariladi:
    So‗rovlar har bir xizmatchaga bittadan guruhga ajratiladi. Har bir guruhda REP
    maydoni bir xil qiymatga ega.
    Har bir guruh uchun guruhga kiruvchi hamma satrlar bo‗yicha AMOUNT ustuni
    o‗rta qiymati hisoblanadi va bitta natijaviy satr hosil qilinadi. Bu qator guruh
    uchun REP ustuni qiymati vash u guruh uchun so‗rov o‗rta qiymatini o‗z ichiga
    oladi.
    SHunday qilib, GROUP BY ifodasi qo‗llanilgan so‗rov, "GURUHLANISHLI
    SO‗ROV " deb ataladi! Shu ifodadan keyin kelgan ustun "guruhlash ustuni "
    deyiladi. Yana bir necha guruhlanishli so‗rovlarni ko‗rib chiqamiz. Har bir ofis
    uchun sotuvlarning rejalashtirilgan xajmi diapazoni qancha?
    SELECT REP_OFFICE, MIN(QUOTA), MAX(QUOTA)
    FROM SALESREPS
    GROUP BY REP_OFFICE
    YAna bir so‗rov: Har bir ofisda qancha xizmatchi ishlaydi?
    SELECT REP_OFFICE, COUNT(*)
    FROM SALESREPS
    GROUP BY REP_OFFICE
    YAna bir guruhlanishli qiziqarli so‗rov: Har bir xizmatchi nechta mijozga xizmat
    ko‗rsatadi?
    SELECT COUNT(DISTINCT CUST_NUM), 'CUSTOMERS FOR SALESREPS',
    CUST_REP
    FROM CUSTOMERS
    GROUP BY CUST_REP
    Bu yerda 'CUSTOMERS FOR SALESREPS' psevdomaydonning ishlatilishiga
    e‘tibor bering. So‗rov natijalarini bir nechta ustun bo‗yicha guruhlash mumkin.
    Masalan, quyidagicha:
    Har bir xizmatchi uchun har bir klient bo‗yicha buyurtmalar umumiy sonini
    hisoblash.
    SELECT REP, CUST, SUM(AMOUNT)
    FROM ORDERS
    GROUP BY REP, CUST
    Lekin ikki ustun bo‗yicha guruhlashda natijalar ikki darajasiga ega guruhlar va
    ostki guruhlar yaratish mumkin emas. Lekin tartiblashni qo‗llash mumkin. Shu
    bilan birga GROUP BY ishlatilganda so‗rov natijalari avtomatik tartiblanadi.
    Quyidagi so‗rovni ko‗ramiz: Har bir xizmatchi uchun har bir klient bo‗yicha
    buyurtmalar umumiy sonini hisoblash; so‗rov natijalarini klientlar va xizmatchilar
    bo‗yicha tartiblash.

    Download 84,3 Kb.
    1   ...   7   8   9   10   11   12   13   14   ...   18




    Download 84,3 Kb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    SELECT REP, AVG(AMOUNT) FROM ORDERS GROUP BY REP

    Download 84,3 Kb.