Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group By Function

Status
Not open for further replies.

itorient

Technical User
Feb 20, 2004
29
0
0
US
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.
 
itorient

I'll try to help you, but you will have to explain a little more, I'm not sure if i understand.
Do you want the times a department sales an item? because it seems like, but according with the results you want, the 101 doesn't fit this criteria.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top