SELECT : שימוש בפונקציות צבירה

  • Published on
    31-Dec-2015

  • View
    34

  • Download
    0

Embed Size (px)

DESCRIPTION

SELECT : . Using Aggregate Functions in SQL Queries. ( Functions Aggregat e ). ( ) ( ) , . - PowerPoint PPT Presentation

Transcript

SELECT: Using Aggregate Functions in SQL Queries1 ( ) ( ) , .: ..

2 (Functions Aggregate)

DBMS . -ORACLE :MAX = MIN = SUM = AVG = COUNT = ( )

3 , 105:SELECT grade FROM Grades WHERE student_id=105;

:SELECT AVG(grade) FROM Grades WHERE student_id=105;

4 1: 105

:SELECT AVG(grade) FROM Grades WHERE student_id=105;

5 1: 105

. :SELECT student_id, AVG(grade) FROM Grades WHERE student_id=105; : DBMS

SELECT MIN(grade), MAX(grade) FROM Grades;

6 2:

SELECT COUNT(student_id)FROM Grades;

. :SELECT COUNT(*)FROM Grades;

7 3:

?SELECT COUNT(student_id)FROM Grades;

! !SELECT COUNT(DISTINCT student_id)FROM Grades;

: -DISTINCT :SELECT DISTINCT COUNT(student_id)FROM Grades;

8 4:

, ' :

9 5: , , SELECT student_id, gradeFROM GradesORDER BY student_id

SELECT student_id, AVG(grade)FROM GradesGROUP BY student_id;

SELECT AVG)A1(, MIN)A7(, A3, A4FROM T1, T2, T3WHERE GROUP BY A2, A3, A410 SELECT 12 34 ?SELECT student_id, course_name, AVG(grade)FROM Grades GROUP BY student_id; : student_id DBMS !

11 6: , , SELECT S.name, ROUND(AVG(G.grade), 2)FROM Grades G, Students SWHERE G.student_id=S.student_idGROUP BY S.student_id, S.name

SELECT student_id, MAX(grade)FROM GradesGROUP BY student_idHAVING AVG(grade)5 OR COUNT(A7)