Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:02,048 --> 00:00:06,400
Now, Let us learn how to find out minimum and maximum value from a particular column
1
2
00:00:07,424 --> 00:00:07,936
For that
2
3
00:00:08,192 --> 00:00:09,984
Min and max functions are used
3
4
00:00:10,496 --> 00:00:13,312
Syntax for using min and max function is as follows
4
5
00:00:13,824 --> 00:00:15,360
You type select
5
6
00:00:16,128 --> 00:00:18,176
Min then you give the expression
6
7
00:00:19,456 --> 00:00:22,528
You can mention other column names also if you want to
7
8
00:00:23,040 --> 00:00:23,552
From
8
9
00:00:24,064 --> 00:00:24,832
Table
9
10
00:00:25,600 --> 00:00:26,368
The table name
10
11
00:00:26,624 --> 00:00:27,136
Where
11
12
00:00:27,648 --> 00:00:29,696
You can specify the where condition if you want to
12
13
00:00:30,464 --> 00:00:34,304
Same is the syntax for max function just you have to replace the min with max
13
14
00:00:36,096 --> 00:00:37,376
Let us look at an example
14
15
00:00:38,400 --> 00:00:39,936
Suppose you want to find out
15
16
00:00:40,192 --> 00:00:44,032
The Minimum sales value that you had in the month of
16
17
00:00:44,800 --> 00:00:46,592
June 2015
17
18
00:00:47,872 --> 00:00:48,640
To do that
18
19
00:00:48,896 --> 00:00:52,224
You need to select the minimum of sales value
19
20
00:00:52,736 --> 00:00:54,016
From the table
20
21
00:00:54,272 --> 00:00:56,064
Where order date is between
21
22
00:00:56,320 --> 00:01:00,160
1st June 2015 and 30th June 2015
22
23
00:01:01,184 --> 00:01:02,720
Let us go and write this query
23
24
00:01:04,000 --> 00:01:07,328
So lets write, select
24
25
00:01:07,584 --> 00:01:09,120
Min
25
26
00:01:11,424 --> 00:01:14,752
The column name is sales
26
27
00:01:16,800 --> 00:01:17,312
As
27
28
00:01:17,568 --> 00:01:19,360
As
28
29
00:01:20,896 --> 00:01:23,200
Minimum sales
29
30
00:01:23,456 --> 00:01:23,968
Value
30
31
00:01:32,672 --> 00:01:33,184
June
31
32
00:01:36,256 --> 00:01:41,632
From the table name where
32
33
00:01:42,656 --> 00:01:45,728
The Order date
33
34
00:01:45,984 --> 00:01:48,800
Is between
34
35
00:01:49,824 --> 00:01:50,848
1st June
35
36
00:01:51,360 --> 00:01:55,456
So we have to write YYYY 2015 is the year
36
37
00:01:55,712 --> 00:01:56,992
MM
37
38
00:01:57,248 --> 00:02:03,392
And DD 1st June and 30 June
38
39
00:02:03,648 --> 00:02:06,208
2015-06-30
39
40
00:02:06,720 --> 00:02:08,000
2016-06-30
40
41
00:02:09,280 --> 00:02:11,072
;
41
42
00:02:11,328 --> 00:02:12,608
Select query
42
43
00:02:12,864 --> 00:02:14,400
And run it
43
44
00:02:16,960 --> 00:02:23,104
So 0.984 is the minimum value of sales order that I received in
44
45
00:02:23,360 --> 00:02:25,664
The month of June 2015
45
46
00:02:28,992 --> 00:02:35,136
To Verify this value let us find out the total sales values and order
46
47
00:02:35,392 --> 00:02:39,744
It into ascending order so that the first value that we have
47
48
00:02:40,768 --> 00:02:43,328
Is the minimum value
48
49
00:02:46,656 --> 00:02:52,800
And order by I hope you remember order by statement
49
50
00:02:54,080 --> 00:02:55,104
Order by
50
51
00:02:55,872 --> 00:02:58,176
Sales ascending
51
52
00:02:58,688 --> 00:03:02,528
If you don't mention it by default is ascending
52
53
00:03:05,344 --> 00:03:06,112
So you can see
53
54
00:03:06,624 --> 00:03:11,232
We have received all the sales values and the minimum is 0.984
54
55
00:03:13,024 --> 00:03:17,888
Now let us work out the maximum value using the max function
55
56
00:03:18,144 --> 00:03:19,424
It Will be exactly same
56
57
00:03:20,960 --> 00:03:24,288
We just change the min to Max
57
58
00:03:24,800 --> 00:03:26,848
So lets just select the query and copy it
58
59
00:03:30,176 --> 00:03:32,992
And change min to Max
59
60
00:03:33,504 --> 00:03:39,136
And rename the column as maximum sales value
60
61
00:03:39,392 --> 00:03:43,232
And run this query
61
62
00:03:46,048 --> 00:03:50,144
The maximum sales value in the month of June 2015 for me was
62
63
00:03:50,400 --> 00:03:52,448
3050
63
64
00:03:52,960 --> 00:03:54,240
Units
64
65
00:03:56,544 --> 00:04:02,688
You can check it by again running the previous query
65
66
00:04:02,944 --> 00:04:06,272
In the descending order so you can see the largest values is
66
67
00:04:06,528 --> 00:04:07,552
3050
67
68
00:04:07,808 --> 00:04:08,576
Unit
68
69
00:04:09,856 --> 00:04:12,928
So this is how we use the Min and Max functions
69
70
00:04:13,440 --> 00:04:16,512
In the next lecture, we will learn about group by function
4896
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.