1
00:00:01,600 --> 00:00:06,200
When we create a reporting table
then it has columns and laws 

2
00:00:06,200 --> 00:00:13,000
after all, it's a table. 
And in these columns and rows, 

3
00:00:13,700 --> 00:00:16,200
which would you prefer the 
columns and rows to be? 

4
00:00:16,200 --> 00:00:20,400
Would you prefer the columns to 
be the list of metrics that say 

5
00:00:20,400 --> 00:00:24,500
that we have 20 metrics like 
some of users? 

6
00:00:24,500 --> 00:00:28,100
Some of the quest, some of 
Click, some of the total revenue

7
00:00:28,400 --> 00:00:29,600
etc. 
Etc. 

8
00:00:30,500 --> 00:00:33,400
And this could be either The 
Columns of the walls and the 

9
00:00:33,400 --> 00:00:37,700
other dimension would be the 
mass of some of clicks per 

10
00:00:37,700 --> 00:00:40,700
month. 
January February, March April, 

11
00:00:40,800 --> 00:00:45,700
The sum of total revenue bill, 
January February, so I would 

12
00:00:45,700 --> 00:00:48,900
prefer the columns to be the 
man's January February. 

13
00:00:48,900 --> 00:00:53,700
March April, May, June, Etc. 
And I would prefer then the 

14
00:00:53,700 --> 00:00:57,000
roads to be the Matrix, because 
then in this way, I can add more

15
00:00:57,000 --> 00:01:01,800
and more Matrix to the holes, 
what the math, stay constants 

16
00:01:02,000 --> 00:01:05,900
and in a single screen and it 
would this would fit my screen 

17
00:01:06,300 --> 00:01:08,700
now. 
Well, such that if I have 100 

18
00:01:08,700 --> 00:01:14,100
Matrix, I could scroll Look at 
all the metrics and I would 

19
00:01:14,100 --> 00:01:17,700
simply see them all one by one 
by month. 

20
00:01:17,700 --> 00:01:21,700
This just makes more sense in. 
This is how most reporting oh 

21
00:01:22,000 --> 00:01:26,300
big to it. 
So in SQL, the thing is that if 

22
00:01:26,300 --> 00:01:30,500
we are on a standard SQL with 
the go by, in order to get these

23
00:01:30,700 --> 00:01:36,000
totals of the Matrix, then when 
we use the go by, then what we 

24
00:01:36,000 --> 00:01:42,100
would get is we would do a goal 
by month and then A sum of all 

25
00:01:42,100 --> 00:01:47,000
the Matrix and we would get a 
wall for each month and condoms 

26
00:01:47,000 --> 00:01:50,500
would be the Matrix. 
Why would it be like this? 

27
00:01:50,500 --> 00:01:55,300
Because the select statement was
the select for the Matrix and 

28
00:01:55,500 --> 00:02:01,700
each thing that we put in the 
select is resulting with another

29
00:02:01,900 --> 00:02:04,500
column. 
This is how select works. 

30
00:02:06,200 --> 00:02:10,500
And the goodbye would result in 
different roles. 

31
00:02:11,100 --> 00:02:14,300
This is where the pivot could 
serve as time we could do this 

32
00:02:14,300 --> 00:02:19,300
manually in SQL. 
But of course you could say that

33
00:02:19,300 --> 00:02:25,400
your reporting system is able to
transform it but we also want to

34
00:02:25,400 --> 00:02:30,200
directly get this result so that
we can iterate upon the scale 

35
00:02:30,200 --> 00:02:35,400
and see the exact results just 
like they're on the reports we 

36
00:02:35,400 --> 00:02:38,400
want to Wait on the scale and 
see the exact same results as 

37
00:02:38,400 --> 00:02:42,000
they would appear on the report 
with Columns, of Demands and the

38
00:02:42,300 --> 00:02:47,000
Wolves of The Matrix. 
So the pivot statements will 

39
00:02:47,000 --> 00:02:49,900
help us with this. 
The pivot statement comes in 

40
00:02:51,000 --> 00:02:57,000
after the form, so we have 
select list of columns form 

41
00:02:57,200 --> 00:03:05,000
which table and then pivot, the 
pivot would receive a few 

42
00:03:05,200 --> 00:03:09,800
parameters. 
So again we have select multiple

43
00:03:09,800 --> 00:03:14,500
columns, that we put to the 
select then form which table and

44
00:03:14,500 --> 00:03:19,700
then pivot in the pivot we say 
just pivot some of the sales for

45
00:03:19,700 --> 00:03:24,100
month in January February. 
So the in but the last part 

46
00:03:24,100 --> 00:03:27,700
would limit the number of months
that we want. 

47
00:03:27,800 --> 00:03:33,100
Basically we just supply to the 
pivot, the aggregate function 

48
00:03:34,200 --> 00:03:41,800
and List of columns that we want
to operate the Aggregate and 

49
00:03:41,800 --> 00:03:47,700
that's it, we would get the 
month as the columns it would 

50
00:03:47,700 --> 00:03:49,800
transform. 
It will get a month as the 

51
00:03:49,800 --> 00:03:52,100
columns because we use the 
pivot. 

52
00:03:52,900 --> 00:03:58,000
So, again, it's a very nice 
scale syntactic sugar. 

53
00:03:59,000 --> 00:04:02,800
But we do a select form, a list 
of columns, then form which 

54
00:04:02,800 --> 00:04:05,400
table. 
And then we do a pivoting based 

55
00:04:05,400 --> 00:04:09,600
on columns, And we say we want 
to pave work by the sum of the 

56
00:04:09,600 --> 00:04:13,200
sales amount for months in 
January, February or March a 

57
00:04:13,200 --> 00:04:20,300
point and then we could select 
another and columns that we want

58
00:04:20,300 --> 00:04:22,800
to Pivot for. 
Not only the sum of the system, 

59
00:04:22,800 --> 00:04:28,600
and also the sum of the clicks, 
the sum of the number of users, 

60
00:04:28,600 --> 00:04:33,000
the sum of the number of 
requests, the sum of the number 

61
00:04:33,000 --> 00:04:36,200
of conversions, the average and 
so forth. 

62
00:04:36,800 --> 00:04:44,500
So this is the the pivot. 
The concept is just to use it 

63
00:04:44,500 --> 00:04:48,100
after the form. 
After we use a select for 

64
00:04:48,100 --> 00:04:52,600
multiple columns we say form, 
which table, and he say in the 

65
00:04:52,600 --> 00:04:56,000
past we said go buy something 
right now. 

66
00:04:56,000 --> 00:05:00,500
Instead of copper, we use pivot 
on this, a pivot by these 

67
00:05:00,500 --> 00:05:05,200
problems, but we also need to 
supply to their pivot which 

68
00:05:05,500 --> 00:05:08,800
other variation. 
Oh, sandwich summaries with want

69
00:05:08,800 --> 00:05:11,100
to. 
So this was the how to use the 

70
00:05:11,100 --> 00:05:15,100
pivot in order to get 
aggregation based on columns. 

71
00:05:06,400 --> 00:05:09,000
Oh, sandwich summaries with want
to. 

72
00:05:09,000 --> 00:05:12,900
So this was the how to use the 
pivot in order to get 

73
00:05:13,100 --> 00:05:15,100
aggregation based on columns.
