Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:01,792 --> 00:00:07,680
Till now we have learnt how to sort filter the data and how to limit the number of rows
1
2
00:00:07,936 --> 00:00:08,960
That we want to
2
3
00:00:09,216 --> 00:00:09,728
Retrieve
3
4
00:00:11,008 --> 00:00:11,520
Now
4
5
00:00:11,776 --> 00:00:17,664
The data that we have received, if you want to get different column name on that table
5
6
00:00:17,920 --> 00:00:19,456
The as keyword is used
6
7
00:00:20,480 --> 00:00:25,088
As will assign an alias to the column name or the table name
7
8
00:00:26,112 --> 00:00:26,880
Why it is used
8
9
00:00:27,392 --> 00:00:32,000
So sometimes you have written a complex function or you have added operators
9
10
00:00:32,256 --> 00:00:34,304
While retrieving the data
10
11
00:00:34,560 --> 00:00:37,120
Your column name will display all those things
11
12
00:00:37,632 --> 00:00:40,192
You want a meaningful name on the column
12
13
00:00:40,448 --> 00:00:41,728
When you have retrieved the data
13
14
00:00:41,984 --> 00:00:43,008
So that is why
14
15
00:00:43,264 --> 00:00:44,800
And as the word is used
15
16
00:00:45,056 --> 00:00:48,128
To provide the second name to that column or to that table
16
17
00:00:49,152 --> 00:00:50,432
What is the syntax for as
17
18
00:00:50,688 --> 00:00:53,248
It is select column name as
18
19
00:00:53,504 --> 00:00:54,528
the alias
19
20
00:00:55,552 --> 00:00:57,088
So you mention the
20
21
00:00:57,600 --> 00:00:58,624
Column name first
21
22
00:00:58,880 --> 00:01:00,928
And then you mention alias
22
23
00:01:01,184 --> 00:01:02,208
From table name
23
24
00:01:02,720 --> 00:01:04,768
You can also mention the table alias
24
25
00:01:05,536 --> 00:01:06,560
For example
25
26
00:01:07,072 --> 00:01:10,656
If you want to give your customer data to some other agency
26
27
00:01:11,168 --> 00:01:13,216
You would like to change the column headers
27
28
00:01:13,728 --> 00:01:16,544
Cust ID will not mean anything to the agency
28
29
00:01:16,800 --> 00:01:19,360
Single change cust ID to serial number
29
30
00:01:19,872 --> 00:01:23,712
Customer underscore name to name and age
30
31
00:01:24,224 --> 00:01:25,504
as Customer's age
31
32
00:01:26,528 --> 00:01:27,808
We'll write this query
32
33
00:01:28,320 --> 00:01:30,112
In the PG admin
33
34
00:01:34,976 --> 00:01:40,352
I am starting the as query now select
34
35
00:01:40,608 --> 00:01:44,448
Customer ID
35
36
00:01:45,984 --> 00:01:47,008
Customer ID as
36
37
00:01:51,872 --> 00:01:52,640
Serial number
37
38
00:01:55,712 --> 00:02:01,856
Since the word serial number has a space in between you need to use the double
38
39
00:02:02,112 --> 00:02:04,672
Quotation mark
39
40
00:02:04,928 --> 00:02:07,744
We need the customer name as name
40
41
00:02:08,256 --> 00:02:11,072
Since name does not have any space bar in between
41
42
00:02:11,328 --> 00:02:12,608
Will not put the
42
43
00:02:13,120 --> 00:02:14,144
Double quotation marks
43
44
00:02:14,400 --> 00:02:18,240
And age we need as the customer age
44
45
00:02:20,032 --> 00:02:21,824
From
45
46
00:02:23,360 --> 00:02:26,176
The table name which is customer
46
47
00:02:27,968 --> 00:02:30,016
Before running this
47
48
00:02:30,272 --> 00:02:32,576
Note that customer ID is written as
48
49
00:02:33,088 --> 00:02:36,160
The column customer ID is showing customer underscore ID
49
50
00:02:36,672 --> 00:02:41,280
Customer name is showing as customer underscore name and age is written as age
50
51
00:02:41,536 --> 00:02:43,072
Now, Let us run this
51
52
00:02:45,376 --> 00:02:46,144
you can see
52
53
00:02:46,400 --> 00:02:47,168
In the output
53
54
00:02:47,680 --> 00:02:49,472
The column name is serial number
54
55
00:02:49,728 --> 00:02:51,776
Name and customer_age
55
56
00:02:53,312 --> 00:02:54,080
Only the aliases
56
57
00:02:54,592 --> 00:02:59,200
that we provided are shown and not the original column name
57
58
00:03:00,224 --> 00:03:06,112
Providing aliases to column names is important when you are having Complex functions mentioned in the query
58
59
00:03:06,624 --> 00:03:11,232
Providing aliases to tables is important when you are using the joins
59
60
00:03:11,488 --> 00:03:16,352
We'll be discussing joins in the later part of the course when we understand the joins will also
60
61
00:03:16,864 --> 00:03:19,424
Revisit the as keyword there
61
62
00:03:19,680 --> 00:03:23,008
So in this lecture we learnt how to provide alias to columns
62
63
00:03:23,776 --> 00:03:27,104
In the next lecture we will learn about some aggregate functions
63
64
00:03:28,128 --> 00:03:30,432
Such as sum, count, average etc
64
65
00:03:30,944 --> 00:03:32,480
See you in the next video
5045
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.