Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:01,280 --> 00:00:04,352
The next and the last function is a string aggregator
1
2
00:00:05,632 --> 00:00:10,496
String aggregator will concatenate all the input values into a single string
2
3
00:00:10,752 --> 00:00:13,056
And all those values will be
3
4
00:00:13,312 --> 00:00:19,456
Separated by a delimiter delimiter is a symbol which you will mention and this symbol will segregate
4
5
00:00:19,712 --> 00:00:21,760
the input values of the string
5
6
00:00:24,320 --> 00:00:25,088
The syntax for
6
7
00:00:25,600 --> 00:00:27,904
String aggregation is string underscore
7
8
00:00:28,416 --> 00:00:29,440
agg
8
9
00:00:29,696 --> 00:00:31,744
and then you mention the expression
9
10
00:00:32,000 --> 00:00:36,352
This will contain the strings or it will contain the column name
10
11
00:00:37,632 --> 00:00:38,144
Comma
11
12
00:00:38,400 --> 00:00:41,984
The delimiter, delimiter usually is a comma
12
13
00:00:42,752 --> 00:00:44,032
You can have space
13
14
00:00:44,288 --> 00:00:47,360
We have tabs you can have any other special symbol
14
15
00:00:49,408 --> 00:00:50,176
Note that
15
16
00:00:50,688 --> 00:00:54,016
String aggregator is also concatenating strings
16
17
00:00:54,528 --> 00:00:59,136
But what is the difference between a string aggregator and the CONCAT operator
17
18
00:01:00,160 --> 00:01:01,440
When we used concat
18
19
00:01:01,952 --> 00:01:02,464
It
19
20
00:01:02,976 --> 00:01:04,512
Concatenated strings
20
21
00:01:05,280 --> 00:01:07,584
Of different column for a single record
21
22
00:01:09,120 --> 00:01:11,168
For example We concatenated
22
23
00:01:11,424 --> 00:01:15,264
City state and country for each customer
23
24
00:01:16,800 --> 00:01:19,360
Where as string aggregator will be used
24
25
00:01:19,616 --> 00:01:22,432
To concatenate all values in a column
25
26
00:01:22,944 --> 00:01:24,736
So for different records
26
27
00:01:25,504 --> 00:01:27,552
There will be different values in that column
27
28
00:01:27,808 --> 00:01:31,136
All those different values can be aggregated
28
29
00:01:31,904 --> 00:01:33,696
Using this string aggregate function
29
30
00:01:34,208 --> 00:01:36,512
Let us look at this using example
30
31
00:01:39,072 --> 00:01:40,864
If you remember from the sales table
31
32
00:01:41,376 --> 00:01:45,472
In the sales table there are different rows for each order
32
33
00:01:45,728 --> 00:01:48,032
And each order had different products
33
34
00:01:49,056 --> 00:01:50,848
So with the same order ID
34
35
00:01:51,104 --> 00:01:52,384
There'll be multiple rows
35
36
00:01:52,896 --> 00:01:59,040
And in these different rows there will be different product IDs. Basically the customer has ordered within a single order
36
37
00:01:59,296 --> 00:02:00,832
Different products
37
38
00:02:01,344 --> 00:02:02,880
If you want to find out
38
39
00:02:03,136 --> 00:02:07,232
What are the products in each order ID
39
40
00:02:08,000 --> 00:02:10,560
So we willl first group the order by order ID
40
41
00:02:10,816 --> 00:02:12,864
And within every order ID
41
42
00:02:13,120 --> 00:02:16,192
We will aggregate the different product IDs
42
43
00:02:16,704 --> 00:02:18,240
And we'll separate these with a
43
44
00:02:18,496 --> 00:02:19,008
Comma
44
45
00:02:20,032 --> 00:02:20,800
This is the
45
46
00:02:21,312 --> 00:02:24,384
Syntax select order ID, string aggregators
46
47
00:02:24,640 --> 00:02:28,736
The product ID separated by comma from sales table group by order ID
47
48
00:02:28,992 --> 00:02:35,136
Let's go and see in the pg Admin. Let us first do a select star on the sales table
48
49
00:02:35,392 --> 00:02:36,160
Just to
49
50
00:02:37,696 --> 00:02:43,840
So that I show you there are different order IDs and product IDs which
50
51
00:02:44,096 --> 00:02:47,168
are taking up different rows in the table
51
52
00:02:51,520 --> 00:02:52,544
You can see
52
53
00:02:55,616 --> 00:02:57,408
this second and third row
53
54
00:02:57,920 --> 00:02:59,712
The order ID is same
54
55
00:03:00,736 --> 00:03:04,064
But this row is different because the product ID is different
55
56
00:03:04,832 --> 00:03:06,624
So I want to find out
56
57
00:03:06,880 --> 00:03:08,416
For each order ID
57
58
00:03:08,672 --> 00:03:10,208
What are the products
58
59
00:03:10,464 --> 00:03:11,744
Ordered. To do that
59
60
00:03:12,000 --> 00:03:12,512
I'll group
60
61
00:03:12,768 --> 00:03:14,048
it by the order ID
61
62
00:03:14,304 --> 00:03:18,912
And against each order ID I'll have the product IDs concatenated
62
63
00:03:19,168 --> 00:03:24,032
Let's see. select order ID
63
64
00:03:27,616 --> 00:03:28,640
And
64
65
00:03:28,896 --> 00:03:32,480
String underscore agg
65
66
00:03:35,808 --> 00:03:38,624
This
66
67
00:03:38,880 --> 00:03:42,464
Column is to be aggregated separated by comma space
67
68
00:03:44,512 --> 00:03:46,816
Comma space
68
69
00:03:49,376 --> 00:03:53,728
From the sales table, grouped by
69
70
00:03:57,824 --> 00:03:59,104
The order ID
70
71
00:04:00,896 --> 00:04:07,040
Let's order it also by the order ID
71
72
00:04:07,296 --> 00:04:09,088
And run it
72
73
00:04:13,696 --> 00:04:17,791
You can see in the sales table there were multiple entries of the same order ID
73
74
00:04:18,047 --> 00:04:22,143
here we have grouped it so it will be a single entry for each order ID
74
75
00:04:22,399 --> 00:04:24,959
Add against that order ID you will see the different
75
76
00:04:25,471 --> 00:04:25,983
Products
76
77
00:04:26,239 --> 00:04:28,543
So this second order ID
77
78
00:04:29,055 --> 00:04:29,567
Has
78
79
00:04:29,823 --> 00:04:31,871
Two products separated by a comma
79
80
00:04:32,127 --> 00:04:33,663
If you go down you will find
80
81
00:04:33,919 --> 00:04:35,455
several order IDs with
81
82
00:04:35,711 --> 00:04:37,247
More than two products also
82
83
00:04:38,783 --> 00:04:42,623
So you can see we have concatenated values in different rows
83
84
00:04:42,879 --> 00:04:45,951
Of the same column the column was product ID
84
85
00:04:46,719 --> 00:04:49,791
So we have concatenated values in different rows
85
86
00:04:50,815 --> 00:04:53,375
So this is what string aggregator function does
86
87
00:04:53,887 --> 00:04:56,191
That is all for the string functions
87
88
00:04:57,215 --> 00:04:59,519
In the next section we will look at Mathematical functions
6841
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.