Hello, I have the following data set that is already grouped by sale_item.
pid sale_item sale_deptno
1 book 101
2 book 101
3 book 102
4 book 103
5 book 101
6 book 101
7 book 102
1 cd 101
2 cd 103
3 cd 102
4 cd 101
1 basket 104
2 basket 100
3 basket 101
Here is what I want to accomplish.
Within the group of sale_item, I would like to count only when there is a change in sale_deptno or count it when there is a break within that group...
And finally sum them up by sale_deptno.
So for this data set:
100 = 1
101 = 5
102 = 3
103 = 2
104 = 1
Any help and expert insight will be appreciated.
pid sale_item sale_deptno
1 book 101
2 book 101
3 book 102
4 book 103
5 book 101
6 book 101
7 book 102
1 cd 101
2 cd 103
3 cd 102
4 cd 101
1 basket 104
2 basket 100
3 basket 101
Here is what I want to accomplish.
Within the group of sale_item, I would like to count only when there is a change in sale_deptno or count it when there is a break within that group...
And finally sum them up by sale_deptno.
So for this data set:
100 = 1
101 = 5
102 = 3
103 = 2
104 = 1
Any help and expert insight will be appreciated.