FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-interview-coding/sql/09.sql at master · andrei-punko/java-interview-coding · GitHub
andrei-punko
/
java-interview-coding
Public
Notifications
You must be signed in to change notification settings
Fork
19
Star
70
Code
Issues
0
Pull requests
0
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-interview-coding
/
sql
/
09.sql
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (23 loc) · 1.29 KB
Breadcrumbs
java-interview-coding
/
sql
/
09.sql
Copy path
File metadata and controls
28 lines (23 loc) · 1.29 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--
09. Написать запрос с использованием агрегатной функции
--
Sql-запросы с агрегатными функциями
--
https://ru.wikipedia.org/wiki/%D0%90%D0%B3%D1%80%D0%B5%D0%B3%D0%B0%D1%82%D0%BD%D1%8B%D0%B5_%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0%B8
--
Агрегатные функции используются для обобщения данных. К их числу относятся:
--
SUM (сумма)
--
MAX(максимальное значение)
--
MIN (минимальное значение)
--
COUNT (количество значений)
--
AVG (среднее значение, обычно среднее арифметическое)
--
MODE (мода)
--
MEDIAN (медиана)
create
table
Orders
(
id
int
primary key
,
amt
int
not null
,
ts
timestamp
not null
);
insert into
Orders
values
(
1
,
3
,
'
2015-07-25 8:53
'
);
insert into
Orders
values
(
2
,
4
,
'
2016-07-25 8:54
'
);
insert into
Orders
values
(
3
,
5
,
'
2018-07-25 8:58
'
);
insert into
Orders
values
(
4
,
6
,
'
2016-09-21 11:00
'
);
insert into
Orders
values
(
5
,
7
,
'
2016-01-13 13:01
'
);
--
Show sum & average `amt` for Orders which `ts` belongs to definite range:
select
sum
(amt),
avg
(amt)
from
Orders
where
ts between
'
2016-01-01
'
and
'
2016-12-31
'
;
Back
|
FazBrowse Home
|
New Git URL